AppDelegate.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #import "AppDelegate.h"
  8. #import <React/RCTBundleURLProvider.h>
  9. #import <React/RCTRootView.h>
  10. #import <React/RCTPushNotificationManager.h>
  11. @implementation AppDelegate
  12. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  13. {
  14. NSURL *jsCodeLocation;
  15. jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  16. RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
  17. moduleName:@"huiliaoAPP"
  18. initialProperties:nil
  19. launchOptions:launchOptions];
  20. rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
  21. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  22. UIViewController *rootViewController = [UIViewController new];
  23. rootViewController.view = rootView;
  24. self.window.rootViewController = rootViewController;
  25. [self.window makeKeyAndVisible];
  26. return YES;
  27. }
  28. // Required to register for notifications
  29. - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  30. {
  31. [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
  32. }
  33. // Required for the register event.
  34. - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  35. {
  36. [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  37. }
  38. // Required for the notification event. You must call the completion handler after handling the remote notification.
  39. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  40. fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  41. {
  42. [RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  43. }
  44. // Required for the registrationError event.
  45. - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  46. {
  47. [RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
  48. }
  49. // Required for the localNotification event.
  50. - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  51. {
  52. [RCTPushNotificationManager didReceiveLocalNotification:notification];
  53. }
  54. @end