Skip to content

Commit

Permalink
Merge pull request #90 from mkapostolov/master
Browse files Browse the repository at this point in the history
Return error callback when the user chooses 'Don't allow' when regist…
  • Loading branch information
EddyVerbruggen authored Jun 1, 2017
2 parents b0b7de7 + d6f855d commit 72751cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ios/AppDelegate+notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/ios/AppDelegate+notification.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions src/ios/PushPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

- (void)register:(CDVInvokedUrlCommand*)command;
- (void)registerUserNotificationSettings:(CDVInvokedUrlCommand*)command;
- (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;

- (void)areNotificationsEnabled:(CDVInvokedUrlCommand*)command;

Expand Down
9 changes: 9 additions & 0 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down

0 comments on commit 72751cc

Please sign in to comment.