|
@@ -12,6 +12,8 @@
|
12
|
12
|
|
13
|
13
|
#import <React/RCTLinkingManager.h>
|
14
|
14
|
#import "RNSplashScreen.h"
|
|
15
|
+#import <RNCPushNotificationIOS.h>
|
|
16
|
+#import <UserNotifications/UserNotifications.h>
|
15
|
17
|
|
16
|
18
|
@implementation AppDelegate
|
17
|
19
|
|
|
@@ -37,10 +39,45 @@
|
37
|
39
|
self.window.rootViewController = rootViewController;
|
38
|
40
|
[self.window makeKeyAndVisible];
|
39
|
41
|
|
|
42
|
+// Define UNUserNotificationCenter
|
|
43
|
+ UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
44
|
+ center.delegate = self;
|
40
|
45
|
[RNSplashScreen show];
|
41
|
46
|
return YES;
|
42
|
47
|
}
|
43
|
48
|
|
|
49
|
+//Called when a notification is delivered to a foreground app.
|
|
50
|
+-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
|
|
51
|
+{
|
|
52
|
+ completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
|
|
53
|
+}
|
|
54
|
+// Required to register for notifications
|
|
55
|
+- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
|
56
|
+{
|
|
57
|
+ [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
|
|
58
|
+}
|
|
59
|
+// Required for the register event.
|
|
60
|
+- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
61
|
+{
|
|
62
|
+ [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
63
|
+}
|
|
64
|
+// Required for the notification event. You must call the completion handler after handling the remote notification.
|
|
65
|
+- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
|
|
66
|
+fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
|
|
67
|
+{
|
|
68
|
+ [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
|
|
69
|
+}
|
|
70
|
+// Required for the registrationError event.
|
|
71
|
+- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
72
|
+{
|
|
73
|
+ [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
|
|
74
|
+}
|
|
75
|
+// Required for the localNotification event.
|
|
76
|
+- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
|
|
77
|
+{
|
|
78
|
+ [RNCPushNotificationIOS didReceiveLocalNotification:notification];
|
|
79
|
+}
|
|
80
|
+
|
44
|
81
|
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
|
45
|
82
|
#ifdef DEBUG
|
46
|
83
|
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
|