Explorar o código

네이버 로그인 설정 - IOS

goodboy %!s(int64=6) %!d(string=hai) anos
pai
achega
1eb64c1da2
Modificáronse 3 ficheiros con 49 adicións e 5 borrados
  1. 14 0
      ios/emptyApp/AppDelegate.m
  2. 10 0
      ios/emptyApp/Info.plist
  3. 25 5
      src/pages/_1_Login.js

+ 14 - 0
ios/emptyApp/AppDelegate.m

@@ -13,11 +13,21 @@
 #import <KakaoOpenSDK/KakaoOpenSDK.h>
 #import <FBSDKCoreKit/FBSDKCoreKit.h>
 #import <RNGoogleSignin/RNGoogleSignin.h>
+#import <NaverThirdPartyLogin/NaverThirdPartyLogin.h>
 
 @implementation AppDelegate
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
+  
+  NaverThirdPartyLoginConnection *thirdConn = [NaverThirdPartyLoginConnection getSharedInstance];
+  //    [thirdConn setOnlyPortraitSupportInIphone:YES];
+  
+  [thirdConn setServiceUrlScheme:kServiceAppUrlScheme];
+  [thirdConn setConsumerKey:kConsumerKey];
+  [thirdConn setConsumerSecret:kConsumerSecret];
+  [thirdConn setAppName:kServiceAppName];
+  
   RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
   RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                    moduleName:@"emptyapp"
@@ -55,6 +65,10 @@
     return [KOSession handleOpenURL:url];
   }
   
+  if([strscheme containsString:naver]) {
+    return [[NaverThirdPartyLoginConnection getSharedInstance] application:application openURL:url options:options];
+  }
+  
   if([strscheme containsString:fb]) {
     return [[FBSDKApplicationDelegate sharedInstance]
             application:application

+ 10 - 0
ios/emptyApp/Info.plist

@@ -46,6 +46,14 @@
 				<string>com.googleusercontent.apps.946601090559-qtilhm3h4fss32ddnvddgnc65autjhqr</string>
 			</array>
 		</dict>
+		<dict>
+			<key>CFBundleTypeRole</key>
+			<string>Editor</string>
+			<key>CFBundleURLSchemes</key>
+			<array>
+				<string>naverorgseonsujoaemptyapp</string>
+			</array>
+		</dict>
 	</array>
 	<key>CFBundleVersion</key>
 	<string>1</string>
@@ -67,6 +75,8 @@
 		<string>fb-messenger-share-api</string>
 		<string>fbauth2</string>
 		<string>fbshareextension</string>
+    <string>naversearchapp</string>
+    <string>naversearchthirdlogin</string>
 	</array>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>

+ 25 - 5
src/pages/_1_Login.js

@@ -10,8 +10,8 @@ C.addColor("#03cf5d", "color-naver");
 const initials = {
   kConsumerKey: 'VWv4bOdB5Bf07a26eJ5h',
   kConsumerSecret: 'pBASnpI7X5',
-  kServiceAppName: 'emptyApp',
-  kServiceAppUrlScheme: 'dooboolaburlscheme', // only for iOS
+  kServiceAppName: 'empty',
+  kServiceAppUrlScheme: 'naverorgseonsujoaemptyapp', // only for iOS
 };
 
 GoogleSignin.configure();
@@ -92,12 +92,12 @@ export default (props)=>{
           console.log(`\n\n  Token is fetched  :: ${token} \n\n`);
           // this.setState(); 
           console.log({ theToken: token });
+          getNaverProfile(token)
           if (err) {
             console.log(err);
             return;
           }
         });
-      
         // return new Promise(function (resolve, reject) {
         //   console.log(props);
         //   NaverLogin.login(props, (err, token) => {
@@ -109,7 +109,26 @@ export default (props)=>{
         //     resolve(token);
         //   });
         // });
-      };  
+      };
+      
+      const getNaverProfile = async(token) => {
+        let result = null;
+        try {
+          result = await getProfile(token);
+        } catch (err) {
+          console.log('err');
+          console.log(err);
+        }
+        console.log(result);
+        return result;
+      }
+      const naverLogout = () => {
+        NaverLogin.logout();
+      }
+
+      const snsLogout = () => {
+        naverLogout();
+      }
     return (
         <C.View cls="jc-sa ai-c flx1 bgc-color-white"> 
             <C.ImageBackground source={require("../res/speech_bubble.png")} 
@@ -158,7 +177,8 @@ export default (props)=>{
 
  
 
-                <C.EL.Button btncls="bgc-color-naver " title="Naver"  onPress={naverLogin}/> 
+                <C.EL.Button btncls="bgc-color-naver " title="Naver"  onPress={naverLogin} /> 
+                <C.EL.Button title="LOG-OUT Any"  onPress={()=> {snsLogout();}} /> 
             </C.View>
         </C.View>
     )