|
@@ -1,10 +1,12 @@
|
|
|
-import React from 'react';
|
|
|
+import React, {useState} from 'react';
|
|
|
import { LoginButton, AccessToken } from 'react-native-fbsdk';
|
|
|
import RNKakao from 'react-native-kakao';
|
|
|
+import { NaverLogin, getProfile } from 'react-native-naver-login';
|
|
|
+import { GoogleSignin, GoogleSigninButton, statusCodes } from 'react-native-google-signin';
|
|
|
+
|
|
|
import C from 'rn-class'
|
|
|
C.addColor("#03cf5d", "color-naver");
|
|
|
|
|
|
-import { NaverLogin, getProfile } from 'react-native-naver-login';
|
|
|
const initials = {
|
|
|
kConsumerKey: 'VWv4bOdB5Bf07a26eJ5h',
|
|
|
kConsumerSecret: 'pBASnpI7X5',
|
|
@@ -12,49 +14,75 @@ const initials = {
|
|
|
kServiceAppUrlScheme: 'dooboolaburlscheme', // only for iOS
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+GoogleSignin.configure();
|
|
|
|
|
|
export default (props)=>{
|
|
|
|
|
|
+ const [userInfo, setUserInfo] = useState(null);
|
|
|
+
|
|
|
+ const googoleSignIn = async () => {
|
|
|
+
|
|
|
+ try {
|
|
|
+ await GoogleSignin.hasPlayServices();
|
|
|
+ const result = await GoogleSignin.signIn();
|
|
|
+
|
|
|
+ console.log(result);
|
|
|
+ } catch (error) {
|
|
|
+ if (error.code === statusCodes.SIGN_IN_CANCELLED) {
|
|
|
+ // user cancelled the login flow
|
|
|
+ console.log('cancel',error);
|
|
|
+ } else if (error.code === statusCodes.IN_PROGRESS) {
|
|
|
+ // operation (f.e. sign in) is in progress already
|
|
|
+ console.log('progress',error);
|
|
|
+ } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
|
|
|
+ // play services not available or outdated
|
|
|
+ console.log('service not available',error);
|
|
|
+ } else {
|
|
|
+ // some other error happened
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const authLogin = () => {
|
|
|
props.navigation.navigate('AcceptTerms');
|
|
|
}
|
|
|
const kakaoLogin = async () => {
|
|
|
try {
|
|
|
const result = await RNKakao.login();
|
|
|
- this.setState({
|
|
|
- userInfo: JSON.stringify(result)
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(result);
|
|
|
} catch (e) {
|
|
|
- this.setState({
|
|
|
- userInfo: `Error: ${e}`
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(`Error: ${e}`);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const kakaoLogout = async () => {
|
|
|
try {
|
|
|
const result = await RNKakao.logout();
|
|
|
- this.setState({
|
|
|
- userInfo: JSON.stringify(result)
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
+ console.log(result);
|
|
|
+
|
|
|
} catch (e) {
|
|
|
- this.setState({
|
|
|
- userInfo: `Error: ${e}`
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(`Error: ${e}`);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
const getUserInfo = async () => {
|
|
|
try {
|
|
|
const result = await RNKakao.userInfo();
|
|
|
- this.setState({
|
|
|
- userInfo: JSON.stringify(result)
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(result);
|
|
|
+
|
|
|
} catch (e) {
|
|
|
- this.setState({
|
|
|
- userInfo: `Error: ${e}`
|
|
|
- });
|
|
|
+
|
|
|
+ console.log(`Error: ${e}`);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -118,8 +146,13 @@ export default (props)=>{
|
|
|
|
|
|
|
|
|
|
|
|
- <C.EL.Button btncls="bgc-color-google-plus " title="Google"/>
|
|
|
-
|
|
|
+ <C.EL.Button btncls="bgc-color-google-plus " title="Google" onPress={googoleSignIn} />
|
|
|
+ {/* <GoogleSigninButton
|
|
|
+ style={{ width: 192, height: 48 }}
|
|
|
+ size={GoogleSigninButton.Size.Wide}
|
|
|
+ color={GoogleSigninButton.Color.Dark}
|
|
|
+ onPress={googoleSignIn}
|
|
|
+ disabled={false} /> */}
|
|
|
|
|
|
<C.EL.Button btncls="bgc-color-kakao " tcls="color-kakaotext" title="Kakao" onPress={kakaoLogin}/>
|
|
|
|