diff --git a/src/ios/AppDelegate+notification.h b/src/ios/AppDelegate+notification.h index 3ab20d81..fc0ecda6 100644 --- a/src/ios/AppDelegate+notification.h +++ b/src/ios/AppDelegate+notification.h @@ -9,6 +9,7 @@ #import "AppDelegate.h" @interface AppDelegate (notification) +- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error; - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo; diff --git a/src/ios/AppDelegate+notification.m b/src/ios/AppDelegate+notification.m index 8adc1a2a..65ecf5e1 100644 --- a/src/ios/AppDelegate+notification.m +++ b/src/ios/AppDelegate+notification.m @@ -76,6 +76,11 @@ - (void)onApplicationDidBecomeActive:(NSNotification *)notification } } +- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { + PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"]; + [pushHandler didRegisterUserNotificationSettings:notificationSettings]; +} + - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { PushPlugin *pushHandler = [self getCommandInstance:@"PushPlugin"]; [pushHandler didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; diff --git a/src/ios/PushPlugin.h b/src/ios/PushPlugin.h index cf20c96a..d4d1ed3e 100644 --- a/src/ios/PushPlugin.h +++ b/src/ios/PushPlugin.h @@ -49,6 +49,7 @@ - (void)register:(CDVInvokedUrlCommand*)command; - (void)registerUserNotificationSettings:(CDVInvokedUrlCommand*)command; +- (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; - (void)areNotificationsEnabled:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index f57daa15..37cf37ee 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -288,6 +288,15 @@ - (void)isEnabled:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)op NSLog(@"JSStatement %@",jsStatement); } */ + + - (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings +{ + // Check if the user has chosen not to recieve notifications for this app + if(notificationSettings.types == UIUserNotificationTypeNone) + { + [self failWithMessage:@"User did not allow notification messages for this app" withError:nil]; + } +} - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {