@@ -68,34 +68,39 @@ + (void) setup:(UIApplication *) application
68
68
selector: @selector (handleTokenRefresh )
69
69
name: kFIRInstanceIDTokenRefreshNotification
70
70
object: nil ];
71
+ }
71
72
73
+ #pragma mark Request permissions
74
+ - (void ) requestPermissions (NSDictionary *)requestedPermissions
75
+ callback : (RCTResponseSenderBlock) callback
76
+ {
72
77
if (SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO (@" 9.0" )) {
73
- UIUserNotificationType allNotificationTypes =
74
- (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
75
- UIUserNotificationSettings *settings =
76
- [UIUserNotificationSettings settingsForTypes: allNotificationTypes categories: nil ];
77
- [[UIApplication sharedApplication ] registerUserNotificationSettings: settings];
78
- } else {
79
- // iOS 10 or later
80
- #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
81
- UNAuthorizationOptions authOptions =
82
- UNAuthorizationOptionAlert
83
- | UNAuthorizationOptionSound
84
- | UNAuthorizationOptionBadge ;
85
- [[UNUserNotificationCenter currentNotificationCenter ]
86
- requestAuthorizationWithOptions: authOptions
87
- completionHandler: ^(BOOL granted, NSError * _Nullable error) {
88
- }
89
- ];
90
-
91
- // For iOS 10 display notification (sent via APNS)
92
- [[UNUserNotificationCenter currentNotificationCenter ] setDelegate: self ];
93
- // For iOS 10 data message (sent via FCM)
94
- [[FIRMessaging messaging ] setRemoteMessageDelegate: self ];
95
- #endif
96
- }
78
+ UIUserNotificationType allNotificationTypes =
79
+ (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
80
+ UIUserNotificationSettings *settings =
81
+ [UIUserNotificationSettings settingsForTypes: allNotificationTypes categories: nil ];
82
+ [[UIApplication sharedApplication ] registerUserNotificationSettings: settings];
83
+ } else {
84
+ // iOS 10 or later
85
+ #if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
86
+ UNAuthorizationOptions authOptions =
87
+ UNAuthorizationOptionAlert
88
+ | UNAuthorizationOptionSound
89
+ | UNAuthorizationOptionBadge ;
90
+ [[UNUserNotificationCenter currentNotificationCenter ]
91
+ requestAuthorizationWithOptions: authOptions
92
+ completionHandler: ^(BOOL granted, NSError * _Nullable error) {
93
+ }
94
+ ];
95
+
96
+ // For iOS 10 display notification (sent via APNS)
97
+ [[UNUserNotificationCenter currentNotificationCenter ] setDelegate: self ];
98
+ // For iOS 10 data message (sent via FCM)
99
+ [[FIRMessaging messaging ] setRemoteMessageDelegate: self ];
100
+ #endif
101
+ }
97
102
98
- [[UIApplication sharedApplication ] registerForRemoteNotifications ];
103
+ [[UIApplication sharedApplication ] registerForRemoteNotifications ];
99
104
}
100
105
101
106
#pragma mark callbacks
0 commit comments