@@ -19,32 +19,32 @@ @implementation RNPNotification
1919+ (NSString *)getStatus
2020{
2121 BOOL didAskForPermission = [[NSUserDefaults standardUserDefaults ] boolForKey: RNPDidAskForNotification];
22- BOOL isRegistered = [[UIApplication sharedApplication ] isRegisteredForRemoteNotifications ];
2322 BOOL isEnabled = [[[UIApplication sharedApplication ] currentUserNotificationSettings ] types ] != UIUserNotificationTypeNone;
24-
25- if (isRegistered || isEnabled) {
26- return isEnabled ? RNPStatusAuthorized : RNPStatusDenied ;
23+
24+ if (isEnabled) {
25+ return RNPStatusAuthorized;
2726 } else {
2827 return didAskForPermission ? RNPStatusDenied : RNPStatusUndetermined;
2928 }
3029}
3130
31+
3232- (void )request : (UIUserNotificationType)types completionHandler : (void (^)(NSString *))completionHandler
3333{
3434 NSString *status = [self .class getStatus ];
35-
35+
3636 if (status == RNPStatusUndetermined) {
3737 self.completionHandler = completionHandler;
38-
38+
3939 [[NSNotificationCenter defaultCenter ] addObserver: self
4040 selector: @selector (applicationDidBecomeActive )
4141 name: UIApplicationDidBecomeActiveNotification
4242 object: nil ];
43-
43+
4444 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes: types categories: nil ];
4545 [[UIApplication sharedApplication ] registerUserNotificationSettings: settings];
4646 [[UIApplication sharedApplication ] registerForRemoteNotifications ];
47-
47+
4848 [[NSUserDefaults standardUserDefaults ] setBool: YES forKey: RNPDidAskForNotification];
4949 [[NSUserDefaults standardUserDefaults ] synchronize ];
5050 } else {
@@ -57,7 +57,7 @@ - (void)applicationDidBecomeActive
5757 [[NSNotificationCenter defaultCenter ] removeObserver: self
5858 name: UIApplicationDidBecomeActiveNotification
5959 object: nil ];
60-
60+
6161 if (self.completionHandler ) {
6262 // for some reason, checking permission right away returns denied. need to wait a tiny bit
6363 dispatch_after (dispatch_time (DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue (), ^{
0 commit comments