customerio-expo-plugin 1.0.0-beta.13 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/helpers/constants/android.js +7 -14
- package/lib/commonjs/helpers/constants/android.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +55 -77
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/PushService.swift +14 -12
- package/lib/commonjs/helpers/utils/codeInjection.js +1 -1
- package/lib/commonjs/helpers/utils/codeInjection.js.map +1 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js +1 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js +16 -14
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +9 -0
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +25 -15
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/PushService.swift +14 -12
- package/lib/module/helpers/utils/codeInjection.js +1 -1
- package/lib/module/helpers/utils/codeInjection.js.map +1 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/ios/withAppDelegateModifications.js +17 -15
- package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +9 -0
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/typescript/helpers/constants/ios.d.ts +1 -3
- package/lib/typescript/helpers/utils/codeInjection.d.ts +1 -1
- package/lib/typescript/types/cio-types.d.ts +5 -0
- package/package.json +2 -2
- package/src/helpers/constants/ios.ts +35 -22
- package/src/helpers/native-files/ios/PushService.swift +14 -12
- package/src/helpers/utils/codeInjection.ts +1 -1
- package/src/helpers/utils/injectCIOPodfileCode.ts +6 -2
- package/src/ios/withAppDelegateModifications.ts +52 -41
- package/src/ios/withNotificationsXcodeProject.ts +36 -1
- package/src/types/cio-types.ts +7 -2
|
@@ -4,18 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_GIST_MAVEN_REGEX = exports.CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_APPLY_REGEX = void 0;
|
|
7
|
-
const CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
|
|
8
|
-
exports.
|
|
9
|
-
const
|
|
10
|
-
exports.
|
|
11
|
-
const
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
14
|
-
exports.CIO_PROJECT_ALLPROJECTS_REGEX = CIO_PROJECT_ALLPROJECTS_REGEX;
|
|
15
|
-
const CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
|
|
16
|
-
exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = CIO_PROJECT_GIST_MAVEN_SNIPPET;
|
|
17
|
-
const CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
|
|
18
|
-
exports.CIO_APP_GOOGLE_SNIPPET = CIO_APP_GOOGLE_SNIPPET;
|
|
19
|
-
const CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
|
|
20
|
-
exports.CIO_PROJECT_GOOGLE_SNIPPET = CIO_PROJECT_GOOGLE_SNIPPET;
|
|
7
|
+
const CIO_PROJECT_BUILDSCRIPTS_REGEX = exports.CIO_PROJECT_BUILDSCRIPTS_REGEX = /(buildscript\s*\{(.|\n)*dependencies\s*\{)/;
|
|
8
|
+
const CIO_APP_APPLY_REGEX = exports.CIO_APP_APPLY_REGEX = /(apply plugin: "com.android.application")/;
|
|
9
|
+
const CIO_GIST_MAVEN_REGEX = exports.CIO_GIST_MAVEN_REGEX = /maven { url "https:\/\/maven.gist.build" }/;
|
|
10
|
+
const CIO_PROJECT_ALLPROJECTS_REGEX = exports.CIO_PROJECT_ALLPROJECTS_REGEX = /(allprojects\s*\{(.|\n){1,500}repositories\s*\{)/;
|
|
11
|
+
const CIO_PROJECT_GIST_MAVEN_SNIPPET = exports.CIO_PROJECT_GIST_MAVEN_SNIPPET = ' maven { url "https://maven.gist.build" }';
|
|
12
|
+
const CIO_APP_GOOGLE_SNIPPET = exports.CIO_APP_GOOGLE_SNIPPET = 'apply plugin: "com.google.gms.google-services" // Google Services plugin';
|
|
13
|
+
const CIO_PROJECT_GOOGLE_SNIPPET = exports.CIO_PROJECT_GOOGLE_SNIPPET = ' classpath "com.google.gms:google-services:4.3.13" // Google Services plugin';
|
|
21
14
|
//# sourceMappingURL=android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","exports","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,
|
|
1
|
+
{"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","exports","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":";;;;;;AAAO,MAAMA,8BAA8B,GAAAC,OAAA,CAAAD,8BAAA,GACzC,4CAA4C;AACvC,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,2CAA2C;AACvE,MAAMC,oBAAoB,GAAAF,OAAA,CAAAE,oBAAA,GAC/B,4CAA4C;AACvC,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GACxC,kDAAkD;AAE7C,MAAMC,8BAA8B,GAAAJ,OAAA,CAAAI,8BAAA,GACzC,kDAAkD;AAC7C,MAAMC,sBAAsB,GAAAL,OAAA,CAAAK,sBAAA,GACjC,2EAA2E;AACtE,MAAMC,0BAA0B,GAAAN,OAAA,CAAAM,0BAAA,GACrC,sFAAsF"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LOCAL_PATH_TO_RN_SDK = exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.
|
|
6
|
+
exports.LOCAL_PATH_TO_RN_SDK = exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_TARGET_NAME = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_INITIALIZECIOSDK_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DEEPLINK_COMMENT_REGEX = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
|
|
7
7
|
exports.getRelativePathToRNSDK = getRelativePathToRNSDK;
|
|
8
8
|
const finder = require('find-package-json');
|
|
9
9
|
const path = require('path');
|
|
@@ -11,83 +11,78 @@ const f = finder(__dirname);
|
|
|
11
11
|
let pluginPackageRoot = f.next().filename;
|
|
12
12
|
// This is the path to the root of the customerio-expo-plugin package
|
|
13
13
|
pluginPackageRoot = path.dirname(pluginPackageRoot);
|
|
14
|
-
const LOCAL_PATH_TO_RN_SDK = path.join(pluginPackageRoot, '../customerio-reactnative');
|
|
15
|
-
exports.
|
|
16
|
-
const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'src/helpers/native-files/ios');
|
|
17
|
-
exports.LOCAL_PATH_TO_CIO_NSE_FILES = LOCAL_PATH_TO_CIO_NSE_FILES;
|
|
14
|
+
const LOCAL_PATH_TO_RN_SDK = exports.LOCAL_PATH_TO_RN_SDK = path.join(pluginPackageRoot, '../customerio-reactnative');
|
|
15
|
+
const LOCAL_PATH_TO_CIO_NSE_FILES = exports.LOCAL_PATH_TO_CIO_NSE_FILES = path.join(pluginPackageRoot, 'src/helpers/native-files/ios');
|
|
18
16
|
function getRelativePathToRNSDK(currentFile) {
|
|
19
17
|
return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK);
|
|
20
18
|
}
|
|
21
|
-
const IOS_DEPLOYMENT_TARGET = '13.0';
|
|
22
|
-
exports.
|
|
23
|
-
const
|
|
24
|
-
exports.
|
|
25
|
-
const
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
28
|
-
exports.
|
|
29
|
-
const
|
|
30
|
-
exports.
|
|
31
|
-
const
|
|
32
|
-
exports.
|
|
33
|
-
const
|
|
34
|
-
exports.
|
|
35
|
-
const
|
|
36
|
-
exports.
|
|
37
|
-
const
|
|
38
|
-
exports.
|
|
39
|
-
const
|
|
40
|
-
exports.
|
|
41
|
-
const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = /^\s*RCTBridge\s*\*\s*\w+\s*=\s*\[\s*self\.reactDelegate\s+createBridgeWithDelegate:self\s+launchOptions:launchOptions\s*\];\s*$/gm;
|
|
42
|
-
exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
43
|
-
const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = /^\s*return\s\[\s*super\s*application:\s*application\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\];/gm;
|
|
44
|
-
exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
45
|
-
const CIO_DEEPLINK_COMMENT_REGEX = /\sDeep link workaround for app killed state start/gm;
|
|
46
|
-
exports.CIO_DEEPLINK_COMMENT_REGEX = CIO_DEEPLINK_COMMENT_REGEX;
|
|
47
|
-
const DEFAULT_BUNDLE_VERSION = '1';
|
|
48
|
-
exports.DEFAULT_BUNDLE_VERSION = DEFAULT_BUNDLE_VERSION;
|
|
49
|
-
const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
50
|
-
exports.DEFAULT_BUNDLE_SHORT_VERSION = DEFAULT_BUNDLE_SHORT_VERSION;
|
|
51
|
-
const CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
52
|
-
exports.CIO_TARGET_NAME = CIO_TARGET_NAME;
|
|
53
|
-
const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
54
|
-
exports.CIO_NOTIFICATION_TARGET_NAME = CIO_NOTIFICATION_TARGET_NAME;
|
|
55
|
-
const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;
|
|
56
|
-
exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = CIO_APPDELEGATEHEADER_IMPORT_SNIPPET;
|
|
57
|
-
const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = 'UNUserNotificationCenterDelegate';
|
|
58
|
-
exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET;
|
|
59
|
-
const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
|
|
19
|
+
const IOS_DEPLOYMENT_TARGET = exports.IOS_DEPLOYMENT_TARGET = '13.0';
|
|
20
|
+
const GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
21
|
+
const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
22
|
+
const BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
23
|
+
const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = /.*\[super(\s)application:application(\s)didFinishLaunchingWithOptions:launchOptions\];/;
|
|
24
|
+
const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = /return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/;
|
|
25
|
+
const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = /(- \(void\)application:\(UIApplication \*\)application didFailToRegisterForRemoteNotificationsWithError:\(NSError \*\)error(\s|\n)*?\{)(.|\n){2}.*\n\}/;
|
|
26
|
+
const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = /return \[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\];/;
|
|
27
|
+
const CIO_APPDELEGATEDECLARATION_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = /@implementation AppDelegate(.|\n)/;
|
|
28
|
+
const CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEHEADER_REGEX = /(@interface AppDelegate\s*:\s*EXAppDelegateWrapper\s*)(<([^>]+)>)?/;
|
|
29
|
+
const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = /^\s*RCTBridge\s*\*\s*\w+\s*=\s*\[\s*self\.reactDelegate\s+createBridgeWithDelegate:self\s+launchOptions:launchOptions\s*\];\s*$/gm;
|
|
30
|
+
const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = /^\s*return\s\[\s*super\s*application:\s*application\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\];/gm;
|
|
31
|
+
const CIO_DEEPLINK_COMMENT_REGEX = exports.CIO_DEEPLINK_COMMENT_REGEX = /\sDeep link workaround for app killed state start/gm;
|
|
32
|
+
const DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_VERSION = '1';
|
|
33
|
+
const DEFAULT_BUNDLE_SHORT_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
|
|
34
|
+
const CIO_TARGET_NAME = exports.CIO_TARGET_NAME = 'CustomerIOSDK';
|
|
35
|
+
const CIO_NOTIFICATION_TARGET_NAME = exports.CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
|
|
36
|
+
const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;
|
|
37
|
+
const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = 'UNUserNotificationCenterDelegate';
|
|
38
|
+
const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `
|
|
60
39
|
CIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];
|
|
61
40
|
`;
|
|
62
|
-
exports.
|
|
63
|
-
const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `
|
|
41
|
+
const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `
|
|
64
42
|
RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];
|
|
65
43
|
`;
|
|
66
|
-
exports.
|
|
67
|
-
const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `
|
|
44
|
+
const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = exports.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `
|
|
68
45
|
return [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;
|
|
69
|
-
exports.
|
|
70
|
-
const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
46
|
+
const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
71
47
|
[super application:application didFailToRegisterForRemoteNotificationsWithError:error];
|
|
72
48
|
[pnHandlerObj application:application error:error];
|
|
73
49
|
`;
|
|
74
|
-
exports.
|
|
75
|
-
const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
|
|
50
|
+
const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
|
|
76
51
|
[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
77
52
|
return [pnHandlerObj application:application deviceToken:deviceToken];
|
|
78
53
|
`;
|
|
79
|
-
exports.
|
|
80
|
-
const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
54
|
+
const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
81
55
|
// Register for push notifications
|
|
82
56
|
[pnHandlerObj registerPushNotification];
|
|
83
57
|
`;
|
|
84
|
-
exports.
|
|
85
|
-
|
|
58
|
+
const CIO_INITIALIZECIOSDK_SNIPPET = exports.CIO_INITIALIZECIOSDK_SNIPPET = `
|
|
59
|
+
[pnHandlerObj initializeCioSdk];
|
|
60
|
+
|
|
61
|
+
// Code to make the CIO SDK compatible with expo-notifications package.
|
|
62
|
+
//
|
|
63
|
+
// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.
|
|
64
|
+
// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app
|
|
65
|
+
// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated
|
|
66
|
+
// click handler in iOS at runtime.
|
|
67
|
+
//
|
|
68
|
+
// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects
|
|
69
|
+
// that another SDK or host iOS app has already set itself as the click handler:
|
|
70
|
+
// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37
|
|
71
|
+
// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.
|
|
72
|
+
//
|
|
73
|
+
// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code.
|
|
74
|
+
# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
75
|
+
// Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,
|
|
76
|
+
// no push metrics reporting will occur.
|
|
77
|
+
// EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];
|
|
78
|
+
|
|
79
|
+
// ...instead, get the singleton reference from Expo.
|
|
80
|
+
id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];
|
|
86
81
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
87
|
-
center.delegate =
|
|
82
|
+
center.delegate = notificationCenterDelegate;
|
|
83
|
+
# endif
|
|
88
84
|
`;
|
|
89
|
-
exports.
|
|
90
|
-
const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `
|
|
85
|
+
const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `
|
|
91
86
|
// Deep link workaround for app killed state start
|
|
92
87
|
NSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];
|
|
93
88
|
if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
|
@@ -101,23 +96,7 @@ NSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWith
|
|
|
101
96
|
}
|
|
102
97
|
//Deep link workaround for app killed state ends
|
|
103
98
|
`;
|
|
104
|
-
|
|
105
|
-
// Enable push handling - notification response
|
|
106
|
-
exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET;
|
|
107
|
-
const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `
|
|
108
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {
|
|
109
|
-
[pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
110
|
-
}`;
|
|
111
|
-
|
|
112
|
-
// Foreground push handling
|
|
113
|
-
exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET;
|
|
114
|
-
const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
|
|
115
|
-
// show push when the app is in foreground
|
|
116
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
117
|
-
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
|
|
118
|
-
}`;
|
|
119
|
-
exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET;
|
|
120
|
-
const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
|
|
99
|
+
const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
|
|
121
100
|
@objc(registerPushNotification)
|
|
122
101
|
public func registerPushNotification() {
|
|
123
102
|
|
|
@@ -130,5 +109,4 @@ const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `
|
|
|
130
109
|
}
|
|
131
110
|
}
|
|
132
111
|
}`;
|
|
133
|
-
exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
134
112
|
//# sourceMappingURL=ios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["finder","require","path","f","__dirname","pluginPackageRoot","next","filename","dirname","LOCAL_PATH_TO_RN_SDK","join","exports","LOCAL_PATH_TO_CIO_NSE_FILES","getRelativePathToRNSDK","currentFile","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const finder = require('find-package-json');\nconst path = require('path');\n\nconst f = finder(__dirname);\nlet pluginPackageRoot = f.next().filename;\n// This is the path to the root of the customerio-expo-plugin package\npluginPackageRoot = path.dirname(pluginPackageRoot);\n\nexport const LOCAL_PATH_TO_RN_SDK = path.join(\n pluginPackageRoot,\n '../customerio-reactnative'\n)\n\nexport const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(\n pluginPackageRoot,\n 'src/helpers/native-files/ios'\n);\n\nexport function getRelativePathToRNSDK(currentFile: string) {\n return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK);\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /.*\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /(@interface AppDelegate\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = \n/^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = \n/^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX = /\\sDeep link workaround for app killed state start/gm;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET = `\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = self;\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n"],"mappings":";;;;;;;AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;A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4DAAA,GAAAA,4DAAA;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA;AACA,CAAC;AAAC5B,OAAA,CAAA4B,4DAAA,GAAAA,4DAAA;AAEK,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;AAAC7B,OAAA,CAAA6B,2CAAA,GAAAA,2CAAA;AAEK,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,CAAC;AAAC9B,OAAA,CAAA8B,iDAAA,GAAAA,iDAAA;AAEK,MAAMC,yCAAyC,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AAAA/B,OAAA,CAAA+B,yCAAA,GAAAA,yCAAA;AACO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AAAAhC,OAAA,CAAAgC,iDAAA,GAAAA,iDAAA;AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAACjC,OAAA,CAAAiC,0CAAA,GAAAA,0CAAA;AACI,MAAMC,qCAAqC,GAAI;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAAClC,OAAA,CAAAkC,qCAAA,GAAAA,qCAAA"}
|
|
1
|
+
{"version":3,"names":["finder","require","path","f","__dirname","pluginPackageRoot","next","filename","dirname","LOCAL_PATH_TO_RN_SDK","exports","join","LOCAL_PATH_TO_CIO_NSE_FILES","getRelativePathToRNSDK","currentFile","relative","IOS_DEPLOYMENT_TARGET","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const finder = require('find-package-json');\nconst path = require('path');\n\nconst f = finder(__dirname);\nlet pluginPackageRoot = f.next().filename;\n// This is the path to the root of the customerio-expo-plugin package\npluginPackageRoot = path.dirname(pluginPackageRoot);\n\nexport const LOCAL_PATH_TO_RN_SDK = path.join(\n pluginPackageRoot,\n '../customerio-reactnative'\n);\n\nexport const LOCAL_PATH_TO_CIO_NSE_FILES = path.join(\n pluginPackageRoot,\n 'src/helpers/native-files/ios'\n);\n\nexport function getRelativePathToRNSDK(currentFile: string) {\n return path.relative(path.dirname(currentFile), LOCAL_PATH_TO_RN_SDK);\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /.*\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /(@interface AppDelegate\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n"],"mappings":";;;;;;;AAAA,MAAMA,MAAM,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAC3C,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAM,CAAC;AAE5B,MAAME,CAAC,GAAGH,MAAM,CAACI,SAAS,CAAC;AAC3B,IAAIC,iBAAiB,GAAGF,CAAC,CAACG,IAAI,CAAC,CAAC,CAACC,QAAQ;AACzC;AACAF,iBAAiB,GAAGH,IAAI,CAACM,OAAO,CAACH,iBAAiB,CAAC;AAE5C,MAAMI,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAGP,IAAI,CAACS,IAAI,CAC3CN,iBAAiB,EACjB,2BACF,CAAC;AAEM,MAAMO,2BAA2B,GAAAF,OAAA,CAAAE,2BAAA,GAAGV,IAAI,CAACS,IAAI,CAClDN,iBAAiB,EACjB,8BACF,CAAC;AAEM,SAASQ,sBAAsBA,CAACC,WAAmB,EAAE;EAC1D,OAAOZ,IAAI,CAACa,QAAQ,CAACb,IAAI,CAACM,OAAO,CAACM,WAAW,CAAC,EAAEL,oBAAoB,CAAC;AACvE;AAEO,MAAMO,qBAAqB,GAAAN,OAAA,CAAAM,qBAAA,GAAG,MAAM;AACpC,MAAMC,+BAA+B,GAAAP,OAAA,CAAAO,+BAAA,GAAG,wBAAwB;AAChE,MAAMC,mCAAmC,GAAAR,OAAA,CAAAQ,mCAAA,GAAG,4BAA4B;AACxE,MAAMC,6BAA6B,GAAAT,OAAA,CAAAS,6BAAA,GAAG,sBAAsB;AAC5D,MAAMC,kCA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AA4B,4DAAA,GAAI;AAC7E;AACA;AACA,CAAC;AAEM,MAAMC,4DAA4D,GAAA7B,OAAA,CAAA6B,4DAAA,GAAI;AAC7E;AACA;AACA,CAAC;AAEM,MAAMC,2CAA2C,GAAA9B,OAAA,CAAA8B,2CAAA,GAAI;AAC5D;AACA;AACA,CAAC;AAEM,MAAMC,4BAA4B,GAAA/B,OAAA,CAAA+B,4BAAA,GAAI;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,yCAAyC,GAAAhC,OAAA,CAAAgC,yCAAA,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qCAAqC,GAAAjC,OAAA,CAAAiC,qCAAA,GAAI;AACtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI"}
|
|
@@ -11,6 +11,20 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
11
11
|
|
|
12
12
|
{{REGISTER_SNIPPET}}
|
|
13
13
|
|
|
14
|
+
@objc(initializeCioSdk)
|
|
15
|
+
public func initializeCioSdk() {
|
|
16
|
+
// Must initialize Customer.io before initializing MessagingPushAPN.
|
|
17
|
+
CustomerIO.initialize(siteId: "{{SITE_ID}}", apiKey: "{{API_KEY}}", region: .{{REGION}}) { config in
|
|
18
|
+
// Must configure auto track push events before initializing MessagingPushAPN.
|
|
19
|
+
// This is because after AppDelegate.didFinishLaunching is called, the app will start handling push click events.
|
|
20
|
+
// Configuring auto track push events after this point will not work.
|
|
21
|
+
config.autoTrackPushEvents = {{AUTO_TRACK_PUSH_EVENTS}}
|
|
22
|
+
}
|
|
23
|
+
MessagingPushAPN.initialize { config in
|
|
24
|
+
config.showPushAppInForeground = {{SHOW_PUSH_APP_IN_FOREGROUND}}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
@objc(application:deviceToken:)
|
|
15
29
|
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
16
30
|
MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
|
|
@@ -20,16 +34,4 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
20
34
|
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
21
35
|
MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
|
|
22
36
|
}
|
|
23
|
-
|
|
24
|
-
@objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
|
|
25
|
-
public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
26
|
-
let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
|
|
27
|
-
withCompletionHandler: completionHandler)
|
|
28
|
-
|
|
29
|
-
// If the Customer.io SDK does not handle the push, it's up to you to handle it and call the
|
|
30
|
-
// completion handler. If the SDK did handle it, it called the completion handler for you.
|
|
31
|
-
if !handled {
|
|
32
|
-
completionHandler()
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","injectCodeBeforeMultiLineRegex","replaceCodeByRegex","matchRegexExists","regex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function injectCodeBeforeMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}\\n$&`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function matchRegexExists(fileContent: string, regex: RegExp) {\n return regex.test(fileContent);\n}\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n"],"mappings":";;;;;;;;;;;;AAAO,SAASA,iBAAiBA,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;AAChB;AAEO,SAASE,0BAA0BA,CACxCX,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,OAAMC,OAAQ,EAAC,CAAC;AACzD;AAEO,SAASW,8BAA8BA,CAC5Cb,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,MAAK,CAAC;AACzD;AAEO,SAASY,kBAAkBA,CAChCd,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAEC,OAAO,CAAC;AAChD;AAEO,SAASa,gBAAgBA,CAACf,WAAmB,EAAEgB,KAAa,EAAE;EACnE,OAAOA,KAAK,CAACR,IAAI,CAACR,WAAW,CAAC;AAChC;AACO,SAASiB,wCAAwCA,CACtDjB,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,OAAOF,WAAW,CAACY,OAAO,CAACX,SAAS,EAAG,GAAEC,OAAQ,EAAC,CAAC;AACrD;AAEO,SAASgB,sBAAsBA,CACpClB,WAAmB,EACnBK,KAAa,EACbH,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,IAAIK,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAAC,EAAEH,OAAO,EAAE,GAAGC,KAAK,CAACO,KAAK,CAACL,KAAK,CAAC,CAAC;EACtE;EAEA,OAAOI,OAAO;
|
|
1
|
+
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","injectCodeBeforeMultiLineRegex","replaceCodeByRegex","matchRegexExists","regex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber","join"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function injectCodeBeforeMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}\\n$&`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function matchRegexExists(fileContent: string, regex: RegExp) {\n return regex.test(fileContent);\n}\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;AAAO,SAASA,iBAAiBA,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,K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,IAAI,CAAC;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ios","require","_codeInjection","_fileManagement","injectCIOPodfileCode","iosPath","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","getRelativePathToRNSDK","trim","write","injectCodeByRegex","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/apn', :path => '${getRelativePathToRNSDK(filename)}'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/apn', :path => '${getRelativePathToRNSDK(filename)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEO,eAAeG,oBAAoBA,CAACC,OAAe,EAAE;EAC1D,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAI,GAAEH,OAAQ,UAAS;EACrC,MAAMI,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAI;AACtC,EAAEV,UAAW;AACb,gDAAgD,IAAAW,2BAAsB,
|
|
1
|
+
{"version":3,"names":["_ios","require","_codeInjection","_fileManagement","injectCIOPodfileCode","iosPath","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","getRelativePathToRNSDK","trim","write","injectCodeByRegex","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/apn', :path => '${getRelativePathToRNSDK(\n filename\n )}'\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n console.log('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks']\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/apn', :path => '${getRelativePathToRNSDK(\n filename\n )}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEO,eAAeG,oBAAoBA,CAACC,OAAe,EAAE;EAC1D,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,G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AAM,CAAClB,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withCIOAndroid","require","_withCIOIos","withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA;AACA,SAASE,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEA,OAAOJ,MAAM;AACf;AAAC,IAAAM,QAAA,
|
|
1
|
+
{"version":3,"names":["_withCIOAndroid","require","_withCIOIos","withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type { CustomerIOPluginOptions } from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA;AACA,SAASE,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEA,OAAOJ,MAAM;AACf;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcT,oBAAoB"}
|
|
@@ -9,9 +9,6 @@ var _Paths = require("@expo/config-plugins/build/ios/Paths");
|
|
|
9
9
|
var _ios = require("../helpers/constants/ios");
|
|
10
10
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
11
11
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
12
|
-
const pushCodeSnippets = [_ios.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, _ios.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
|
|
13
|
-
const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join newlines and ensure a newline at the end.
|
|
14
|
-
|
|
15
12
|
const addImport = (stringContents, appName) => {
|
|
16
13
|
const importRegex = /^(#import .*)\n/gm;
|
|
17
14
|
const addedImport = getImportSnippet(appName);
|
|
@@ -24,7 +21,7 @@ const addImport = (stringContents, appName) => {
|
|
|
24
21
|
// Add after first import:
|
|
25
22
|
endOfMatchIndex = match.index + match[0].length;
|
|
26
23
|
}
|
|
27
|
-
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport)
|
|
24
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport);
|
|
28
25
|
return stringContents;
|
|
29
26
|
};
|
|
30
27
|
const addNotificationHandlerDeclaration = stringContents => {
|
|
@@ -35,8 +32,8 @@ const addNotificationConfiguration = stringContents => {
|
|
|
35
32
|
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
|
|
36
33
|
return stringContents;
|
|
37
34
|
};
|
|
38
|
-
const
|
|
39
|
-
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.
|
|
35
|
+
const addInitializeNativeCioSdk = stringContents => {
|
|
36
|
+
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.CIO_INITIALIZECIOSDK_SNIPPET);
|
|
40
37
|
return stringContents;
|
|
41
38
|
};
|
|
42
39
|
const addHandleDeeplinkInKilledStateConfiguration = (stringContents, regex) => {
|
|
@@ -51,8 +48,15 @@ const addDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
|
|
|
51
48
|
stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
|
|
52
49
|
return stringContents;
|
|
53
50
|
};
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
|
|
52
|
+
// Adds required import for Expo Notifications package in AppDelegate.
|
|
53
|
+
// Required to call functions from the package.
|
|
54
|
+
const addExpoNotificationsHeaderModification = stringContents => {
|
|
55
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, 0, `
|
|
56
|
+
#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
57
|
+
#import <EXNotifications/EXNotificationCenterDelegate.h>
|
|
58
|
+
#endif
|
|
59
|
+
`);
|
|
56
60
|
return stringContents;
|
|
57
61
|
};
|
|
58
62
|
const addAppdelegateHeaderModification = stringContents => {
|
|
@@ -82,8 +86,8 @@ const addHandleDeeplinkInKilledState = stringContents => {
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
// Check if the app delegate is using RCTBridge or LaunchOptions
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
let snippet = undefined;
|
|
90
|
+
let regex = _ios.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
87
91
|
if ((0, _codeInjection.matchRegexExists)(stringContents, _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
88
92
|
snippet = _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;
|
|
89
93
|
regex = _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
@@ -114,15 +118,13 @@ const withAppDelegateModifications = (configOuter, props) => {
|
|
|
114
118
|
if (props.disableNotificationRegistration !== undefined && props.disableNotificationRegistration === false) {
|
|
115
119
|
stringContents = addNotificationConfiguration(stringContents);
|
|
116
120
|
}
|
|
117
|
-
|
|
118
|
-
stringContents = addUserNotificationCenterConfiguration(stringContents);
|
|
119
|
-
}
|
|
121
|
+
stringContents = addInitializeNativeCioSdk(stringContents);
|
|
120
122
|
if (props.handleDeeplinkInKilledState !== undefined && props.handleDeeplinkInKilledState === true) {
|
|
121
123
|
stringContents = addHandleDeeplinkInKilledState(stringContents);
|
|
122
124
|
}
|
|
123
|
-
stringContents = addAdditionalMethodsForPushNotifications(stringContents);
|
|
124
125
|
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
125
126
|
stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
127
|
+
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
126
128
|
config.modResults.contents = stringContents;
|
|
127
129
|
} else {
|
|
128
130
|
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_Paths","_ios","_codeInjection","_fileManagement","pushCodeSnippets","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","injectCodeBeforeMultiLineRegex","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addUserNotificationCenterConfiguration","CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET","addHandleDeeplinkInKilledStateConfiguration","regex","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","addDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addAdditionalMethodsForPushNotifications","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","addAppdelegateHeaderModification","replace","CIO_APPDELEGATEHEADER_REGEX","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","trim","addHandleDeeplinkInKilledState","matchRegexExists","CIO_DEEPLINK_COMMENT_REGEX","snippet","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","replaceCodeByRegex","withAppDelegateModifications","configOuter","props","withAppDelegate","config","modResults","contents","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","disableNotificationRegistration","handleNotificationClick","handleDeeplinkInKilledState","console","log","exports"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addUserNotificationCenterConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKUSERNOTIFICATIONCENTER_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (stringContents: string, regex: RegExp) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (existingDelegates && existingDelegates.includes(CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET)) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n var snippet = undefined\n var regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (matchRegexExists(stringContents, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n }\n else if (matchRegexExists(stringContents, CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(stringContents, regex);\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents\n}\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n if (\n props.handleNotificationClick === undefined ||\n props.handleNotificationClick === true\n ) {\n stringContents = addUserNotificationCenterConfiguration(stringContents);\n }\n\n if (\n props.handleDeeplinkInKilledState !== undefined &&\n props.handleDeeplinkInKilledState === true\n ) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n \n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAuBA,IAAAG,cAAA,GAAAH,OAAA;AAQA,IAAAI,eAAA,GAAAJ,OAAA;AAGA,MAAMK,gBAAgB,GAAG,CACvBC,sDAAiD,EACjDC,+CAA0C,CAC3C;AAED,MAAMC,qCAAqC,GAAI,GAAEH,gBAAgB,CAACI,IAAI,CACpE,IACF,CAAE,IAAG,CAAC,CAAC;;AAEP,MAAMC,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;EACjD;EAEAT,cAAc,GAAG,IAAAU,qCAAsB,EACrCV,cAAc,EACdM,eAAe,EACfH,WACF,CAAC,CAACL,IAAI,CAAC,IAAI,CAAC;EAEZ,OAAOE,cAAc;AACvB,CAAC;AAED,MAAMW,iCAAiC,GAAIX,cAAsB,IAAK;EACpEA,cAAc,GAAG,IAAAY,yCAA0B,EACzCZ,cAAc,EACda,qCAAgC,EAChCC,mDACF,CAAC;EAED,OAAOd,cAAc;AACvB,CAAC;AAED,MAAMe,4BAA4B,GAAIf,cAAsB,IAAK;EAC/DA,cAAc,GAAG,IAAAgB,6CAA8B,EA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AC,2DAA2D,CAAC;IAC1E;IAEA,OAAOjB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACkB,OAAA,CAAAtB,4BAAA,GAAAA,4BAAA;AACF,SAAShD,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_Paths","_ios","_codeInjection","_fileManagement","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","injectCodeBeforeMultiLineRegex","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addInitializeNativeCioSdk","CIO_INITIALIZECIOSDK_SNIPPET","addHandleDeeplinkInKilledStateConfiguration","regex","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","addDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addExpoNotificationsHeaderModification","addAppdelegateHeaderModification","replace","CIO_APPDELEGATEHEADER_REGEX","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","trim","addHandleDeeplinkInKilledState","matchRegexExists","CIO_DEEPLINK_COMMENT_REGEX","snippet","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","replaceCodeByRegex","withAppDelegateModifications","configOuter","props","withAppDelegate","config","modResults","contents","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","disableNotificationRegistration","handleDeeplinkInKilledState","console","log","exports"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n );\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet = undefined;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (\n props.handleDeeplinkInKilledState !== undefined &&\n props.handleDeeplinkInKilledState === true\n ) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n stringContents = addExpoNotificationsHeaderModification(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAoBA,IAAAG,cAAA,GAAAH,OAAA;AAQA,IAAAI,eAAA,GAAAJ,OAAA;AAGA,MAAMK,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAA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,CAAC1C,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZwB,mDAAmD,CAACxB,cAAc,CAAC;MACrEA,cAAc,GACZ4B,mDAAmD,CAAC5B,cAAc,CAAC;MAErEA,cAAc,GAAG+B,sCAAsC,CAAC/B,cAAc,CAAC;MAEvEuD,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGzD,cAAc;IAC7C,CAAC,MAAM;MACLsE,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOhB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACiB,OAAA,CAAArB,4BAAA,GAAAA,4BAAA;AACF,SAAS/C,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
|
|
@@ -248,6 +248,15 @@ const updatePushFile = (options, envFileName) => {
|
|
|
248
248
|
snippet = _ios.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
249
249
|
}
|
|
250
250
|
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGISTER_RE, snippet);
|
|
251
|
+
if (options.pushNotification) {
|
|
252
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{SITE_ID\}\}/, options.pushNotification.env.siteId);
|
|
253
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{API_KEY\}\}/, options.pushNotification.env.apiKey);
|
|
254
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{REGION\}\}/, options.pushNotification.env.region.toUpperCase());
|
|
255
|
+
}
|
|
256
|
+
const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
|
|
257
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
258
|
+
const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
|
|
259
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
251
260
|
_fileManagement.FileManagement.writeFile(envFileName, envFileContent);
|
|
252
261
|
};
|
|
253
262
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|