diff --git a/docs/API.md b/docs/API.md index 0d80178f5..93e088fa1 100644 --- a/docs/API.md +++ b/docs/API.md @@ -73,6 +73,7 @@ All iOS boolean options can also be specified as `string` | `ios.sound` | `boolean` | `false` | Optional. If `true` the device plays a sound on receipt of notification. **Note:** the value you set this option to the first time you call the init method will be how the application always acts. Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>`App Name`. This is normal iOS behaviour. | | `ios.clearBadge` | `boolean` | `false` | Optional. If `true` the badge will be cleared on app startup. | | `ios.categories` | `Object` | `{}` | Optional. The data required in order to enable Action Buttons for iOS. See [Action Buttons on iOS](https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1) for more details. | +| `ios.apnsForce` | `boolean` | `false` | Optional. If `true` it will force APNS to be used even if GoogleServiceInfo.plist is present in the project. If `false` the default behaviour takes over i.e. FCM will be used if GoogleServiceInfo.plist file is present in your project and APNS will be used if GoogleServiceInfo.plist isn't present in your project | #### iOS GCM support diff --git a/src/ios/PushPlugin.m b/src/ios/PushPlugin.m index 0290c8ecc..db55d67c7 100644 --- a/src/ios/PushPlugin.m +++ b/src/ios/PushPlugin.m @@ -161,6 +161,12 @@ - (void)init:(CDVInvokedUrlCommand*)command; { NSMutableDictionary* options = [command.arguments objectAtIndex:0]; NSMutableDictionary* iosOptions = [options objectForKey:@"ios"]; + BOOL apnsForce = false; + id apnsForceArg = [iosOptions objectForKey:@"apnsForce"]; + if (([apnsForceArg isKindOfClass:[NSString class]] && [apnsForceArg isEqualToString:@"true"]) || [apnsForceArg boolValue]) { + apnsForce = true; + NSLog(@"Push Plugin will now use APNS even if GoogleService-Info.plist is present"); + } id voipArg = [iosOptions objectForKey:@"voip"]; if (([voipArg isKindOfClass:[NSString class]] && [voipArg isEqualToString:@"true"]) || [voipArg boolValue]) { [self.commandDelegate runInBackground:^ { @@ -304,7 +310,7 @@ - (void)init:(CDVInvokedUrlCommand*)command; // GCM options [self setFcmSenderId: fcmSenderId]; - if(isGcmEnabled && [[self fcmSenderId] length] > 0) { + if(isGcmEnabled && [[self fcmSenderId] length] > 0 && !apnsForce) { NSLog(@"Using FCM Notification"); [self setUsesFCM: YES]; dispatch_async(dispatch_get_main_queue(), ^{