[text] AppDetegate.m

Viewer

copydownloadembedprintName: AppDetegate.m
  1. /**
  2.  * Copyright (c) 2015-present, Facebook, Inc.
  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.  
  8. #import "AppDelegate.h"
  9.  
  10. #import <UserNotifications/UserNotifications.h>
  11.  
  12. #import <React/RCTBundleURLProvider.h>
  13. #import <React/RCTRootView.h>
  14. #import "RNSplashScreen.h"
  15.  
  16. #if RCT_DEV
  17. #import <React/RCTDevLoadingView.h>
  18. #endif
  19.  
  20. #import <React/RCTLinkingManager.h>
  21.  
  22. #import <RNCPushNotificationIOS.h>
  23.  
  24. #import "SDImageCodersManager.h"
  25. #import <SDWebImageWebPCoder/SDImageWebPCoder.h>
  26.  
  27.  
  28. @implementation AppDelegate
  29. - (BOOL)application:(UIApplication *)application
  30.    openURL:(NSURL *)url
  31.    options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
  32. {
  33.   return [RCTLinkingManager application:application openURL:url options:options];
  34. }
  35.  
  36.  
  37. - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {
  38.   return [RCTLinkingManager application:application
  39.                    continueUserActivity:userActivity
  40.                      restorationHandler:restorationHandler];
  41. }
  42.  
  43. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  44. {
  45.   
  46.   // [IAPPromotionObserver startObserving];
  47.  
  48.   // [FIRApp configure];
  49.   NSURL *jsCodeLocation;
  50.  
  51.   for (NSString* family in [UIFont familyNames])
  52.   {
  53.     NSLog(@"%@", family);
  54.     for (NSString* name in [UIFont fontNamesForFamilyName: family])
  55.     {
  56.       NSLog(@" %@", name);
  57.     }
  58.   }
  59.  
  60.  
  61.   [SDImageCodersManager.sharedManager addCoder:SDImageWebPCoder.sharedCoder];
  62.  
  63.   jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios"];
  64.  
  65.  
  66.   RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
  67.                                             launchOptions:launchOptions];
  68.   
  69.   RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
  70.                                                    moduleName:@"MyApp"
  71.                                             initialProperties:${}];
  72.  
  73.   if (@available(iOS 13.0, *)) {
  74.       rootView.backgroundColor = [UIColor systemBackgroundColor];
  75.   } else {
  76.       rootView.backgroundColor = [UIColor whiteColor];
  77.   }
  78.  
  79.   self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  80.   UIViewController *rootViewController = [UIViewController new];
  81.   rootViewController.view = rootView;
  82.   self.window.rootViewController = rootViewController;
  83.   [self.window makeKeyAndVisible];
  84.   
  85.   [RNSplashScreen show];
  86.   
  87.  
  88.   UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  89.   center.delegate = self;
  90.  
  91.   return YES;
  92. }
  93.  
  94. // Required to register for notifications
  95. - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  96. {
  97.   [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
  98. }
  99. // Required for the register event.
  100. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  101. {
  102.   [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  103. }
  104. // Required for the notification event. You must call the completion handler after handling the remote notification.
  105. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  106. fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  107. {
  108.   [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  109. }
  110. // Required for the registrationError event.
  111. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  112. {
  113.   [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
  114. }
  115. // Required for the localNotification event.
  116. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  117. {
  118.   [RNCPushNotificationIOS didReceiveLocalNotification:notification];
  119. }
  120.  
  121. //Called when a notification is delivered to a foreground app.
  122. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  123. {
  124.   NSLog(@"User Info : %@",notification.request.content.userInfo);
  125.   completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
  126. }
  127.  
  128.  
  129.  
  130.  
  131. @end
  132.  

Editor

You can edit this paste and save as new:


File Description
  • AppDetegate.m
  • Paste Code
  • 01 Oct-2022
  • 4.59 Kb
You can Share it: