Drop use of deprecated currentUserNotificationSettings property in favour of UNUserNotificationCenter.

This commit is contained in:
Doug
2021-07-15 18:23:36 +01:00
parent ff13038264
commit b0ae59d681
+11 -2
View File
@@ -2790,10 +2790,19 @@ TableViewSectionsDelegate>
}
- (void)togglePushNotifications:(id)sender
{
// Get the user's notification settings to check check authorization status.
[[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
dispatch_async(dispatch_get_main_queue(), ^{
[self togglePushNotifications:sender withNotificationSettings:settings];
});
}];
}
- (void)togglePushNotifications:(id)sender withNotificationSettings:(UNNotificationSettings * _Nonnull)settings
{
// Check first whether the user allow notification from device settings
UIUserNotificationType currentUserNotificationTypes = UIApplication.sharedApplication.currentUserNotificationSettings.types;
if (currentUserNotificationTypes == UIUserNotificationTypeNone)
if (settings.authorizationStatus == UNAuthorizationStatusDenied)
{
[currentAlert dismissViewControllerAnimated:NO completion:nil];