Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'AGCORDOVA-25'
Browse files Browse the repository at this point in the history
  • Loading branch information
cvasilak committed Aug 12, 2014
2 parents c3de575 + 6679567 commit d6c1f39
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/ios/PushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,20 @@ - (void)register:(CDVInvokedUrlCommand *)command; {
[self.commandDelegate runInBackground:^{
NSMutableDictionary *options = [self parseOptions:command];
[self saveConfig:options];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert
| UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound];

// when running under iOS 8 we will use the new API for APNS registration
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

#else
[[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
#endif

CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
Expand Down Expand Up @@ -74,7 +86,7 @@ - (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
[self.commandDelegate evalJs:@"cordova.require('org.jboss.aerogear.cordova.push.AeroGear.UnifiedPush').successCallback()"];
} failure:^(NSError *error) {
NSString *errorMessage = [NSString stringWithFormat:@"Push registration Error: %@", error];
NSLog(errorMessage);
NSLog(@"%@", errorMessage);
CDVPluginResult *commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:errorMessage];
[self.commandDelegate sendPluginResult:commandResult callbackId:self.callbackId];
}];
Expand Down

0 comments on commit d6c1f39

Please sign in to comment.