Skip to content

Commit

Permalink
feat: support promises and error code (#67)
Browse files Browse the repository at this point in the history
* support promises and error code
- feat: support promises
- feat: support error code partially
- doc: update readme
- update examples and types

merge migration
- index.d.ts changing merged into index.ts
- renaming podspec file react-native-kakao-logins to RNSKakaoLogin
- added postinstall command to Examples for build typescript project(file:../)

* docs(readme): fix module name as proper version

(cherry picked from commit ee9340e)

* skip: applying review

(cherry picked from commit 85b65d4)

* fix: yarn and pod reinstall for refresh lock files

* skip: applying review

* skip: remove legacy logs and comment
  • Loading branch information
bang9 authored and heyman333 committed Oct 21, 2019
1 parent 9d1f332 commit b329e59
Show file tree
Hide file tree
Showing 10 changed files with 714 additions and 626 deletions.
1 change: 1 addition & 0 deletions KakaoLoginExample/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ yarn-error.log
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
Expand Down
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']);
Binary file added KakaoLoginExample/android/app/debug.keystore
Binary file not shown.
14 changes: 7 additions & 7 deletions KakaoLoginExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ PODS:
- DoubleConversion
- glog
- glog (0.3.5)
- kakao-login (1.0.1-rc2):
- KakaoOpenSDK (~> 1.16.0)
- React
- KakaoOpenSDK (1.16.0):
- KakaoOpenSDK/KakaoCommon (= 1.16.0)
- KakaoOpenSDK/KakaoLink (= 1.16.0)
Expand Down Expand Up @@ -69,9 +72,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 Down Expand Up @@ -101,14 +101,14 @@ DEPENDENCIES:
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- "kakao-login (from `../node_modules/@react-native-seoul/kakao-login`)"
- React (from `../node_modules/react-native/`)
- React-Core (from `../node_modules/react-native/React`)
- React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`)
- React-DevSupport (from `../node_modules/react-native/React`)
- 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 @@ -133,6 +133,8 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/Folly.podspec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
kakao-login:
:path: "../node_modules/@react-native-seoul/kakao-login"
React:
:path: "../node_modules/react-native/"
React-Core:
Expand All @@ -147,8 +149,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 Down Expand Up @@ -177,6 +177,7 @@ SPEC CHECKSUMS:
DoubleConversion: 5805e889d232975c086db112ece9ed034df7a0b2
Folly: 30e7936e1c45c08d884aa59369ed951a8e68cf51
glog: 1f3da668190260b06b429bb211bfbee5cd790c28
kakao-login: 2d5e711ce534f79eab1fc7f0e5aaaa31918e8b46
KakaoOpenSDK: 453413b65b71ef3c732c070606d3a557ac4e01d1
React: 53c53c4d99097af47cf60594b8706b4e3321e722
React-Core: ba421f6b4f4cbe2fb17c0b6fc675f87622e78a64
Expand All @@ -185,7 +186,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 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 install && yarn build",
"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

0 comments on commit b329e59

Please sign in to comment.