AppDelegate.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import "AppDelegate.h"
  8. #import <React/RCTBridge.h>
  9. #import <React/RCTBundleURLProvider.h>
  10. #import <React/RCTRootView.h>
  11. #import <KakaoOpenSDK/KakaoOpenSDK.h>
  12. #import <FBSDKCoreKit/FBSDKCoreKit.h>
  13. #import <RNGoogleSignin/RNGoogleSignin.h>
  14. #import <NaverThirdPartyLogin/NaverThirdPartyLogin.h>
  15. @implementation AppDelegate
  16. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  17. {
  18. NaverThirdPartyLoginConnection *thirdConn = [NaverThirdPartyLoginConnection getSharedInstance];
  19. // [thirdConn setOnlyPortraitSupportInIphone:YES];
  20. [thirdConn setServiceUrlScheme:kServiceAppUrlScheme];
  21. [thirdConn setConsumerKey:kConsumerKey];
  22. [thirdConn setConsumerSecret:kConsumerSecret];
  23. [thirdConn setAppName:kServiceAppName];
  24. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  25. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
  26. moduleName:@"emptyapp"
  27. initialProperties:nil];
  28. rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  29. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  30. UIViewController *rootViewController = [UIViewController new];
  31. rootViewController.view = rootView;
  32. self.window.rootViewController = rootViewController;
  33. [self.window makeKeyAndVisible];
  34. return YES;
  35. }
  36. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  37. sourceApplication:(NSString *)sourceApplication
  38. annotation:(id)annotation {
  39. if ([KOSession isKakaoAccountLoginCallback:url]) {
  40. return [KOSession handleOpenURL:url];
  41. }
  42. return false;
  43. }
  44. - (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
  45. NSString *strscheme = [url scheme];
  46. NSString *naver = @"naver";
  47. NSString *fb = @"fb";
  48. NSString *google = @"com.googleusercontent";
  49. if ([KOSession isKakaoAccountLoginCallback:url]) {
  50. return [KOSession handleOpenURL:url];
  51. }
  52. if([strscheme containsString:naver]) {
  53. return [[NaverThirdPartyLoginConnection getSharedInstance] application:application openURL:url options:options];
  54. }
  55. if([strscheme containsString:fb]) {
  56. return [[FBSDKApplicationDelegate sharedInstance]
  57. application:application
  58. openURL:url
  59. sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
  60. annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  61. }
  62. if([strscheme containsString:google]) {
  63. return [RNGoogleSignin application:application
  64. openURL:url
  65. sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
  66. annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
  67. }
  68. return false;
  69. }
  70. - (void)applicationDidBecomeActive:(UIApplication *)application
  71. {
  72. [KOSession handleDidBecomeActive];
  73. }
  74. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  75. {
  76. #if DEBUG
  77. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  78. #else
  79. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  80. #endif
  81. }
  82. @end