Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  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.  
  8. #import "AppDelegate.h"
  9. #import <React/RCTBridge.h>
  10. #import <React/RCTBundleURLProvider.h>
  11. #import <React/RCTRootView.h>
  12. #import <RNCPushNotificationIOS.h>
  13. #import <UserNotifications/UserNotifications.h>
  14.  
  15. @implementation AppDelegate
  16.  
  17. // Required to register for notifications
  18. - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  19. {
  20. [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
  21. }
  22. // Required for the register event.
  23. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  24. {
  25. [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  26. }
  27. // Required for the notification event. You must call the completion handler after handling the remote notification.
  28. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  29. fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  30. {
  31. [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  32. }
  33. // Required for the registrationError event.
  34. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  35. {
  36. [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
  37. }
  38. // Required for the localNotification event.
  39. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  40. {
  41. [RNCPushNotificationIOS didReceiveLocalNotification:notification];
  42. }
  43.  
  44. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  45. {
  46. RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  47. RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
  48. moduleName:@"APPNAME"
  49. initialProperties:nil];
  50.  
  51. rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  52.  
  53. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  54. UIViewController *rootViewController = [UIViewController new];
  55. rootViewController.view = rootView;
  56. UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  57. center.delegate = self;
  58. self.window.rootViewController = rootViewController;
  59. [self.window makeKeyAndVisible];
  60. return YES;
  61. }
  62.  
  63. // Called when a notification is delivered to a foreground app.
  64. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  65. {
  66. completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
  67. }
  68.  
  69. - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  70. {
  71. #if DEBUG
  72. return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  73. #else
  74. return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  75. #endif
  76. }
  77.  
  78. #if RCT_DEV
  79. - (BOOL)bridge:(RCTBridge *)bridge didNotFindModule:(NSString *)moduleName {
  80. return YES;
  81. }
  82. #endif
  83.  
  84. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement