Commit 2bd3b802 by Frank Gregor

Fixes wrong completionHandler call

In case of iOS 10+ the call to grant permission was made outside of the `requestAuthorizationWithOptions(..)` block and returned immediately with `PermissionStatusGranted` which leads to a totally useless permission request.
parent 30314d66
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
completionHandler(PermissionStatusDenied); completionHandler(PermissionStatusDenied);
return; return;
} }
[[UIApplication sharedApplication] registerForRemoteNotifications];
completionHandler(PermissionStatusGranted);
}]; }];
} else { } else {
UIUserNotificationType notificationTypes = 0; UIUserNotificationType notificationTypes = 0;
notificationTypes |= UIUserNotificationTypeSound; notificationTypes |= UIUserNotificationTypeSound;
...@@ -45,9 +49,10 @@ ...@@ -45,9 +49,10 @@
notificationTypes |= UIUserNotificationTypeBadge; notificationTypes |= UIUserNotificationTypeBadge;
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil]; UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
completionHandler(PermissionStatusGranted);
} }
[[UIApplication sharedApplication] registerForRemoteNotifications];
completionHandler(PermissionStatusGranted);
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment