77
88#import " AppDelegate.h"
99
10+ #import < RNCPushNotificationIOS.h>
1011#import < React/RCTBridge.h>
1112#import < React/RCTBundleURLProvider.h>
1213#import < React/RCTRootView.h>
13- #import < RNCPushNotificationIOS.h>
14- #import < UserNotifications/UserNotifications.h>
1514
1615#if DEBUG
1716#import < FlipperKit/FlipperClient.h>
1817#import < FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
19- #import < FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
2018#import < FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
21- #import < SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
2219#import < FlipperKitReactPlugin/FlipperKitReactPlugin.h>
20+ #import < FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
21+ #import < SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
2322static void InitializeFlipper (UIApplication *application) {
2423 FlipperClient *client = [FlipperClient sharedClient ];
25- SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc ] initWithDefaults ];
26- [client addPlugin: [[FlipperKitLayoutPlugin alloc ] initWithRootNode: application withDescriptorMapper: layoutDescriptorMapper]];
24+ SKDescriptorMapper *layoutDescriptorMapper =
25+ [[SKDescriptorMapper alloc ] initWithDefaults ];
26+ [client addPlugin: [[FlipperKitLayoutPlugin alloc ]
27+ initWithRootNode: application
28+ withDescriptorMapper: layoutDescriptorMapper]];
2729 [client addPlugin: [[FKUserDefaultsPlugin alloc ] initWithSuiteName: nil ]];
2830 [client addPlugin: [FlipperKitReactPlugin new ]];
29- [client addPlugin: [[FlipperKitNetworkPlugin alloc ] initWithNetworkAdapter: [SKIOSNetworkAdapter new ]]];
31+ [client addPlugin: [[FlipperKitNetworkPlugin alloc ]
32+ initWithNetworkAdapter: [SKIOSNetworkAdapter new ]]];
3033 [client start ];
3134}
3235#endif
3336
3437@implementation AppDelegate
3538
36- - (BOOL )application : (UIApplication *)application didFinishLaunchingWithOptions : ( NSDictionary *) launchOptions
37- {
39+ - (BOOL )application : (UIApplication *)application
40+ didFinishLaunchingWithOptions : ( NSDictionary *) launchOptions {
3841
39- #if DEBUG
42+ #if DEBUG
4043 InitializeFlipper (application);
41- #endif
44+ #endif
4245
43- RCTBridge *bridge = [[RCTBridge alloc ] initWithDelegate: self launchOptions: launchOptions];
46+ RCTBridge *bridge = [[RCTBridge alloc ] initWithDelegate: self
47+ launchOptions: launchOptions];
4448 RCTRootView *rootView = [[RCTRootView alloc ] initWithBridge: bridge
4549 moduleName: @" example"
4650 initialProperties: nil ];
4751
48- rootView.backgroundColor = [[UIColor alloc ] initWithRed: 1 .0f green: 1 .0f blue: 1 .0f alpha: 1 ];
52+ rootView.backgroundColor = [[UIColor alloc ] initWithRed: 1 .0f
53+ green: 1 .0f
54+ blue: 1 .0f
55+ alpha: 1 ];
4956
5057 self.window = [[UIWindow alloc ] initWithFrame: [UIScreen mainScreen ].bounds];
5158 UIViewController *rootViewController = [UIViewController new ];
@@ -54,59 +61,72 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5461 [self .window makeKeyAndVisible ];
5562
5663 // Define UNUserNotificationCenter
57- UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter ];
64+ UNUserNotificationCenter *center =
65+ [UNUserNotificationCenter currentNotificationCenter ];
5866 center.delegate = self;
5967
6068 return YES ;
6169}
6270
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 );
71+ // Called when a notification is delivered to a foreground app.
72+ - (void )userNotificationCenter : (UNUserNotificationCenter *)center
73+ willPresentNotification : (UNNotification *)notification
74+ withCompletionHandler :
75+ (void (^)(UNNotificationPresentationOptions options))
76+ completionHandler {
77+ completionHandler (UNAuthorizationOptionSound | UNAuthorizationOptionAlert |
78+ UNAuthorizationOptionBadge );
6779}
6880
6981// Required to register for notifications
70- - (void )application : (UIApplication *)application didRegisterUserNotificationSettings : (UIUserNotificationSettings *)notificationSettings
71- {
72- [RNCPushNotificationIOS didRegisterUserNotificationSettings: notificationSettings];
82+ - (void )application : (UIApplication *)application
83+ didRegisterUserNotificationSettings :
84+ (UIUserNotificationSettings *)notificationSettings {
85+ [RNCPushNotificationIOS
86+ didRegisterUserNotificationSettings: notificationSettings];
7387}
7488// Required for the register event.
75- - (void )application : (UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken
76- {
77- [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken: deviceToken];
89+ - (void )application : (UIApplication *)application
90+ didRegisterForRemoteNotificationsWithDeviceToken : (NSData *)deviceToken {
91+ [RNCPushNotificationIOS
92+ didRegisterForRemoteNotificationsWithDeviceToken: deviceToken];
7893}
79- // Required for the notification event. You must call the completion handler after handling the remote notification.
80- - (void )application : (UIApplication *)application didReceiveRemoteNotification : (NSDictionary *)userInfo
81- fetchCompletionHandler : (void (^)(UIBackgroundFetchResult))completionHandler
82- {
83- [RNCPushNotificationIOS didReceiveRemoteNotification: userInfo fetchCompletionHandler: completionHandler];
94+ // Required for the notification event. You must call the completion handler
95+ // after handling the remote notification.
96+ - (void )application : (UIApplication *)application
97+ didReceiveRemoteNotification : (NSDictionary *)userInfo
98+ fetchCompletionHandler :
99+ (void (^)(UIBackgroundFetchResult))completionHandler {
100+ [RNCPushNotificationIOS didReceiveRemoteNotification: userInfo
101+ fetchCompletionHandler: completionHandler];
84102}
85103// Required for the registrationError event.
86- - (void )application : (UIApplication *)application didFailToRegisterForRemoteNotificationsWithError : (NSError *)error
87- {
88- [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError: error];
104+ - (void )application : (UIApplication *)application
105+ didFailToRegisterForRemoteNotificationsWithError : (NSError *)error {
106+ [RNCPushNotificationIOS
107+ didFailToRegisterForRemoteNotificationsWithError: error];
89108}
90109// Required for the localNotification event.
91- - (void )application : (UIApplication *)application didReceiveLocalNotification : (UILocalNotification *) notification
92- {
93- [RNCPushNotificationIOS didReceiveLocalNotification: notification];
110+ - (void )application : (UIApplication *)application
111+ didReceiveLocalNotification : (UILocalNotification *) notification {
112+ [RNCPushNotificationIOS didReceiveLocalNotification: notification];
94113}
95114// IOS 10+ Required for local notification tapped event
96115- (void )userNotificationCenter : (UNUserNotificationCenter *)center
97- didReceiveNotificationResponse : (UNNotificationResponse *)response
98- withCompletionHandler : (void (^)(void ))completionHandler
99- {
116+ didReceiveNotificationResponse : (UNNotificationResponse *)response
117+ withCompletionHandler : (void (^)(void ))completionHandler {
100118 [RNCPushNotificationIOS didReceiveNotificationResponse: response];
101119 completionHandler ();
102120}
103121
104- - (NSURL *)sourceURLForBridge : (RCTBridge *)bridge
105- {
122+ - (NSURL *)sourceURLForBridge : (RCTBridge *)bridge {
106123#if DEBUG
107- return [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: @" index" fallbackResource: nil ];
124+ return
125+ [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: @" index"
126+ fallbackResource: nil ];
108127#else
109- return [[NSBundle mainBundle ] URLForResource: @" main" withExtension: @" jsbundle" ];
128+ return [[NSBundle mainBundle ] URLForResource: @" main"
129+ withExtension: @" jsbundle" ];
110130#endif
111131}
112132
0 commit comments