From 0940dc914fed63ab9fb394c3e68ebd9a7ef9d4de Mon Sep 17 00:00:00 2001 From: Christy Thomas Alex <34361280+ChrisTomAlx@users.noreply.github.com> Date: Wed, 3 Apr 2019 16:54:27 +0530 Subject: [PATCH 1/2] Added boolean iosOption apnsForce to force apns Default : False [Uses FCM if GoogleServiceInfo.plist is present and APNS if not] If set to true (Boolean) or "true" (String) within ios options in init, it will force APNS to be used even if GoogleServiceInfo.plist is present in the project --- src/ios/PushPlugin.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(), ^{ From 2d7bd4eb258421d6a9b4145a6f4a21fe3ac4fae9 Mon Sep 17 00:00:00 2001 From: Christy Thomas Alex <34361280+ChrisTomAlx@users.noreply.github.com> Date: Wed, 3 Apr 2019 17:00:15 +0530 Subject: [PATCH 2/2] Update API.md --- docs/API.md | 1 + 1 file changed, 1 insertion(+) 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