Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support promises and error code #67

Merged
merged 6 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 42 additions & 33 deletions KakaoLoginExample/App.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, {useState} from 'react';
import {Platform, StyleSheet, Text, View, Image} from 'react-native';
import {Platform, StyleSheet, Text, View, Image, YellowBox} from 'react-native';

import RNKakaoLogins from '@react-native-seoul/kakao-login';
import KakaoLogins from '@react-native-seoul/kakao-login';
import NativeButton from 'apsl-react-native-button';

if (!RNKakaoLogins) {
if (!KakaoLogins) {
console.error('Module is Not Linked');
}

Expand All @@ -31,50 +31,57 @@ export default function App() {
const kakaoLogin = () => {
logCallback('Login Start', setLoginLoading(true));

RNKakaoLogins.login((err, result) => {
if (err) {
return logCallback(
`Login Failed:${err.toString()}`,
setLoginLoading(false),
);
}
setToken(result.token);
logCallback(`Login Finished:${result.token}`, setLoginLoading(false));
});
KakaoLogins.login()
.then(result => {
setToken(result.token);
logCallback(`Login Finished:${result.token}`, setLoginLoading(false));
})
.catch(err => {
if (err.code === 'E_CANCELLED_OPERATION') {
logCallback(`Login Cancelled:${err.message}`, setLoginLoading(false));
} else {
logCallback(
`Login Failed:${err.code} ${err.message}`,
setLoginLoading(false),
);
}
});
};

const kakaoLogout = () => {
logCallback('Logout Start', setLogoutLoading(true));

RNKakaoLogins.logout((err, result) => {
if (err) {
return logCallback(
`Logout Failed:${err.toString()}`,
KakaoLogins.logout()
.then(result => {
setToken(TOKEN_EMPTY);
setProfile(PROFILE_EMPTY);
logCallback(`Logout Finished:${result}`, setLogoutLoading(false));
})
.catch(err => {
logCallback(
`Logout Failed:${err.code} ${err.message}`,
setLogoutLoading(false),
);
}
setToken(TOKEN_EMPTY);
setProfile(PROFILE_EMPTY);
logCallback(`Logout Finished:${result}`, setLogoutLoading(false));
});
});
};

const getProfile = () => {
logCallback('Get Profile Start', setProfileLoading(true));

RNKakaoLogins.getProfile((err, result) => {
if (err) {
return logCallback(
`Get Profile Failed:${err.toString()}`,
KakaoLogins.getProfile()
.then(result => {
setProfile(result);
logCallback(
`Get Profile Finished:${JSON.stringify(result)}`,
setProfileLoading(false),
);
})
.catch(err => {
logCallback(
`Get Profile Failed:${err.code} ${err.message}`,
setProfileLoading(false),
);
}
setProfile(result);
logCallback(
`Get Profile Finished:${JSON.stringify(result)}`,
setProfileLoading(false),
);
});
});
};

const {id, email, profile_image_url: photo} = profile;
Expand Down Expand Up @@ -168,3 +175,5 @@ const styles = StyleSheet.create({
color: '#3d3d3d',
},
});

YellowBox.ignoreWarnings(['source.uri']);
14 changes: 7 additions & 7 deletions KakaoLoginExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ PODS:
- React-cxxreact (= 0.60.5)
- React-jsi (= 0.60.5)
- React-jsinspector (0.60.5)
- @react-native-seoul/kakao-login (1.3.7):
- KakaoOpenSDK (~> 1.16.0)
- React
- React-RCTActionSheet (0.60.5):
- React-Core (= 0.60.5)
- React-RCTAnimation (0.60.5):
Expand All @@ -95,6 +92,9 @@ PODS:
- React-Core (= 0.60.5)
- React-RCTWebSocket (0.60.5):
- React-Core (= 0.60.5)
- RNSKakaoLogin (1.0.0-rc2):
bang9 marked this conversation as resolved.
Show resolved Hide resolved
- KakaoOpenSDK (~> 1.16.0)
- React
- yoga (0.60.5.React)

DEPENDENCIES:
Expand All @@ -108,7 +108,6 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- @react-native-seoul/kakao-login (from `../node_modules/@react-native-seoul/kakao-login`)
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
Expand All @@ -119,6 +118,7 @@ DEPENDENCIES:
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-RCTWebSocket (from `../node_modules/react-native/Libraries/WebSocket`)
- "RNSKakaoLogin (from `../node_modules/@react-native-seoul/kakao-login`)"
hyochan marked this conversation as resolved.
Show resolved Hide resolved
- yoga (from `../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -147,8 +147,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
@react-native-seoul/kakao-login:
:path: "../node_modules/@react-native-seoul/kakao-login"
React-RCTActionSheet:
:path: "../node_modules/react-native/Libraries/ActionSheetIOS"
React-RCTAnimation:
Expand All @@ -169,6 +167,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration"
React-RCTWebSocket:
:path: "../node_modules/react-native/Libraries/WebSocket"
RNSKakaoLogin:
:path: "../node_modules/@react-native-seoul/kakao-login"
yoga:
:path: "../node_modules/react-native/ReactCommon/yoga"

Expand All @@ -185,7 +185,6 @@ SPEC CHECKSUMS:
React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2
React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30
React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4
@react-native-seoul/kakao-login: fa43633accdd13d45e2ef980baa440b130bd9b75
React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90
React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e
React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24
Expand All @@ -196,6 +195,7 @@ SPEC CHECKSUMS:
React-RCTText: b074d89033583d4f2eb5faf7ea2db3a13c7553a2
React-RCTVibration: 2105b2e0e2b66a6408fc69a46c8a7fb5b2fdade0
React-RCTWebSocket: cd932a16b7214898b6b7f788c8bddb3637246ac4
RNSKakaoLogin: ec8a16dc2b31c3cbf161e3767f1684b238a408ea
yoga: 312528f5bbbba37b4dcea5ef00e8b4033fdd9411

PODFILE CHECKSUM: d0eed8782467d6c06f8755e17a4d5b7a9e3d0180
Expand Down
1 change: 1 addition & 0 deletions KakaoLoginExample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"private": true,
"scripts": {
"preinstall": "cd .. && yarn build",
bang9 marked this conversation as resolved.
Show resolved Hide resolved
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"start:packager": "node_modules/react-native/packager/packager.sh",
Expand Down
Loading