| 
				
			 | 
			
			
				@@ -19,35 +19,21 @@ static NSString* RNPDidAskForNotification = @"RNPDidAskForNotification"; 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				 + (NSString *)getStatus 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				     BOOL didAskForPermission = [[NSUserDefaults standardUserDefaults] boolForKey:RNPDidAskForNotification]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+    BOOL isRegistered = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+    BOOL isEnabled = [[[UIApplication sharedApplication] currentUserNotificationSettings] types] != UIUserNotificationTypeNone; 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				24
			 | 
			
			
				      
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-    if (didAskForPermission) { 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-        if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) { 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-            // iOS8+ 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				-            BOOL isRegistered = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications]; 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-            BOOL isEnabled = [[[UIApplication sharedApplication] currentUserNotificationSettings] types] != UIUserNotificationTypeNone; 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-            if (isRegistered || isEnabled) { 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				
			 | 
			
			
				-                return isEnabled ? RNPStatusAuthorized : RNPStatusDenied; 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				-            } 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				
			 | 
			
			
				-            else { 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-                return RNPStatusDenied; 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				-            } 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-        } else { 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				-            if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone) { 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-                return RNPStatusDenied; 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				-            } 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				-            else { 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-                return RNPStatusAuthorized; 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-            } 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+    if (isRegistered || isEnabled) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+        return isEnabled ? RNPStatusAuthorized : RNPStatusDenied; 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				27
			 | 
			
			
				     } else { 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-        return RNPStatusUndetermined; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+        return didAskForPermission ? RNPStatusDenied : RNPStatusUndetermined; 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				29
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				30
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				31
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				47
			 | 
			
				32
			 | 
			
			
				 - (void)request:(UIUserNotificationType)types completionHandler:(void (^)(NSString*))completionHandler 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				33
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-    BOOL didAskForPermission = [[NSUserDefaults standardUserDefaults] boolForKey:RNPDidAskForNotification]; 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-    if (!didAskForPermission) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+    NSString *status = [self.class getStatus]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+    if (status == RNPStatusUndetermined) { 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				37
			 | 
			
			
				         self.completionHandler = completionHandler; 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				38
			 | 
			
			
				          
			 | 
		
	
		
			
			| 
				53
			 | 
			
				39
			 | 
			
			
				         [[NSNotificationCenter defaultCenter] addObserver:self 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -55,19 +41,14 @@ static NSString* RNPDidAskForNotification = @"RNPDidAskForNotification"; 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				41
			 | 
			
			
				                                                      name:UIApplicationDidBecomeActiveNotification 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				42
			 | 
			
			
				                                                    object:nil]; 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				43
			 | 
			
			
				          
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-        if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) { 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-            // iOS8+ 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-            UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-            [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-            [[UIApplication sharedApplication] registerForRemoteNotifications]; 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-        } else { 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-            [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationType)types]; 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				
			 | 
			
			
				-        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+        [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+        [[UIApplication sharedApplication] registerForRemoteNotifications]; 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				47
			 | 
			
			
				          
			 | 
		
	
		
			
			| 
				67
			 | 
			
				48
			 | 
			
			
				         [[NSUserDefaults standardUserDefaults] setBool:YES forKey:RNPDidAskForNotification]; 
			 | 
		
	
		
			
			| 
				68
			 | 
			
				49
			 | 
			
			
				         [[NSUserDefaults standardUserDefaults] synchronize]; 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				50
			 | 
			
			
				     } else { 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				
			 | 
			
			
				-        completionHandler([self.class getStatus]); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+        completionHandler(status); 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				52
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				53
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				54
			 | 
			
			
				  
			 |