From 008046433bf11aa16e11480fefe26aa32c4f8568 Mon Sep 17 00:00:00 2001 From: reza Date: Thu, 30 Jul 2015 23:20:56 -0700 Subject: [PATCH] Fixed the issue where if user disable notification, plugin wouldn't call the error handler --- src/ios/PushPlugin.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 7686ae9d..4281aa47 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -52,6 +52,16 @@ - (void)register:(CDVInvokedUrlCommand*)command; #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 UIUserNotificationType UserNotificationTypes = UIUserNotificationTypeNone; #endif + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 + // Check if notification is disabled by user, and call error handler if no notification is enabled + UIUserNotificationSettings *currentUserNotificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings]; + + if (!currentUserNotificationSettings || (currentUserNotificationSettings.types == UIUserNotificationTypeNone)) { + [self failWithMessage:@"User disabled all notifications." withError:nil]; + } +#endif + UIRemoteNotificationType notificationTypes = UIRemoteNotificationTypeNone; id badgeArg = [options objectForKey:@"badge"];