diff --git a/SwrvePlugin/swrve-utils/hooks/ios-after_plugin_install.js b/SwrvePlugin/swrve-utils/hooks/ios-after_plugin_install.js index 97e0666..44a2f09 100644 --- a/SwrvePlugin/swrve-utils/hooks/ios-after_plugin_install.js +++ b/SwrvePlugin/swrve-utils/hooks/ios-after_plugin_install.js @@ -39,6 +39,7 @@ function iosSetupAppDelegate() { const swrveStack = appConfig.getPlatformPreference('swrve.stack', 'ios'); const clearPushBadgeOnStartup = appConfig.getPlatformPreference('swrve.clearPushBadgeOnStartup', 'ios'); + const autoCollectDeviceToken = appConfig.getPlatformPreference('swrve.autoCollectDeviceToken', 'ios'); // returns 'true' if the appDelegate had to be modified var needsModification = swrveIntegration.modifyAppDelegate(appDelegatePath); @@ -57,6 +58,7 @@ function iosSetupAppDelegate() { swrveIntegration.setPushCapabilities( appDelegatePath, appGroupIdentifier, + swrveUtils.convertToBoolean(autoCollectDeviceToken), swrveUtils.convertToBoolean(clearPushBadgeOnStartup) ); diff --git a/SwrvePlugin/swrve-utils/hooks/swrve-ios-integration.js b/SwrvePlugin/swrve-utils/hooks/swrve-ios-integration.js index 5881e4c..3ba9ac6 100644 --- a/SwrvePlugin/swrve-utils/hooks/swrve-ios-integration.js +++ b/SwrvePlugin/swrve-utils/hooks/swrve-ios-integration.js @@ -74,7 +74,7 @@ var self = (module.exports = { swrveUtils.searchAndReplace(delegatePath, searchFor, replaceWith); }, - setPushCapabilities: function(delegatePath, appGroupIdentifier, clearPushBadgeOnStartup) { + setPushCapabilities: function(delegatePath, appGroupIdentifier,autoCollectDeviceToken, clearPushBadgeOnStartup ) { let searchFor = []; let replaceWith = []; // Read in the required data for edits @@ -112,6 +112,13 @@ var self = (module.exports = { ); } + if (!autoCollectDeviceToken) { + searchFor.push('config.pushEnabled = true;'); + replaceWith.push( + `config.pushEnabled = true; \n config.autoCollectDeviceToken = false;` + ); + } + swrveUtils.searchAndReplace(delegatePath, searchFor, replaceWith); },