Thans
@Erel but the solution you mention I have already looked for it. We need to go a little further.
For example, an app that only request notifications when an user action is held in the app then the app queries:
Is the first time the user request notifications?
We tell the user that we need notifications (MSGBOX) with Continue or Cancel. If it chooses continue, then we request the notifications from the App and the user is presented with the Allow/Don't Allow dialogue.
If the user chooses Don't Allow, I cancel the request. When he chooses again the request, then I cannot present the user with the RegisterForRemoteNotifications because he already denied it, so I have to take him to the app settings so he can allow manually (prev MSGBOX warning the user)
This last point is where the old code does not work. I have tried with another piece ob OBJC with no luch, as it is not a direct return method. This snippet returns Authorized, not Authorized or Denied, which would be perfect whith my request. But I cannot figure out how to return the value within this OBJC when OSVersion>8 under the CompletionHandler
#import <UserNotifications/UserNotifications.h>
- (VOID)checkPerms{
if #available(iOS 9, *) {
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
switch (settings.authorizationStatus) {
case UNAuthorizationStatusAuthorized:
NSLog(@"Status Authorized");
break;
case UNAuthorizationStatusDenied:
NSLog(@"Status Denied");
break;
case UNAuthorizationStatusNotDetermined:
NSLog(@"Undetermined");
break;
default:
break;
}
}];
}else{
if UIApplication.shared.isRegisteredForRemoteNotifications {
NSLog(@"Status Denied");
} else {
NSLog(@"Status Authorized");
}
}
}