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"];