I’ve a option to get push permissions.
However what I get each time will not be the right worth.
How can I rewrite this technique?
My push permission has been enabled, nevertheless it nonetheless prints out 555 first after which 111.
However after I name this technique outdoors, I’ve already obtained False first.
How can I make the entire technique regular?
- (BOOL)getNotificationPermission
{
__block BOOL hasPermission;
UNUserNotificationCenter *heart = [UNUserNotificationCenter currentNotificationCenter];
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings){
switch (settings.authorizationStatus) {
case UNAuthorizationStatusAuthorized:
hasPermission = YES;
NSLog(@"111");
break;
case UNAuthorizationStatusDenied:
hasPermission = NO;
NSLog(@"222");
break;
case UNAuthorizationStatusNotDetermined:
hasPermission = NO;
NSLog(@"333");
break;
default:
hasPermission = NO;
NSLog(@"444");
break;
}
}];
NSLog(@"555");
return hasPermission;
}
Log
555
111