customerio-expo-plugin 1.0.0-beta.9 → 2.0.0-beta.1
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/README.md +8 -5
- package/package.json +32 -24
- package/plugin/app.plugin.js +1 -0
- package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withCIOAndroid.js +2 -0
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectStrings.js +70 -0
- package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -0
- package/plugin/lib/commonjs/helpers/constants/android.js +14 -0
- package/{lib → plugin/lib}/commonjs/helpers/constants/android.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/ios.js +119 -0
- package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/Env.swift +7 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/NotificationService.swift +25 -0
- package/{src → plugin/lib/commonjs}/helpers/native-files/ios/PushService.swift +10 -13
- package/{lib → plugin/lib}/commonjs/helpers/utils/codeInjection.js +9 -1
- package/plugin/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +50 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +26 -0
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/index.js +1 -2
- package/{lib → plugin/lib}/commonjs/index.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/ios/withAppDelegateModifications.js +63 -9
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/ios/withCIOIos.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/ios/withNotificationsXcodeProject.js +30 -34
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/ios/withXcodeProject.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/postInstall.js.map +1 -1
- package/plugin/lib/commonjs/postInstallHelper.js +22 -0
- package/plugin/lib/commonjs/postInstallHelper.js.map +1 -0
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -0
- package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withAppGoogleServices.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withCIOAndroid.js +2 -0
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -0
- package/{lib → plugin/lib}/module/android/withGistMavenRepository.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withProjectStrings.js +63 -0
- package/plugin/lib/module/android/withProjectStrings.js.map +1 -0
- package/{lib → plugin/lib}/module/helpers/constants/android.js.map +1 -1
- package/{lib → plugin/lib}/module/helpers/constants/globals.d.js.map +1 -1
- package/plugin/lib/module/helpers/constants/ios.js +112 -0
- package/plugin/lib/module/helpers/constants/ios.js.map +1 -0
- package/plugin/lib/module/helpers/native-files/ios/Env.swift +7 -0
- package/plugin/lib/module/helpers/native-files/ios/NotificationService.swift +25 -0
- package/{lib → plugin/lib}/module/helpers/native-files/ios/PushService.swift +10 -13
- package/{lib → plugin/lib}/module/helpers/utils/codeInjection.js +7 -1
- package/plugin/lib/module/helpers/utils/codeInjection.js.map +1 -0
- package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +43 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/plugin/lib/module/helpers/utils/pluginUtils.js +19 -0
- package/plugin/lib/module/helpers/utils/pluginUtils.js.map +1 -0
- package/{lib → plugin/lib}/module/index.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js +136 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -0
- package/{lib → plugin/lib}/module/ios/withCIOIos.js.map +1 -1
- package/{lib → plugin/lib}/module/ios/withNotificationsXcodeProject.js +30 -33
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/module/ios/withXcodeProject.js.map +1 -1
- package/{lib → plugin/lib}/module/postInstall.js.map +1 -1
- package/plugin/lib/module/postInstallHelper.js +20 -0
- package/plugin/lib/module/postInstallHelper.js.map +1 -0
- package/plugin/lib/module/types/cio-types.js.map +1 -0
- package/plugin/lib/typescript/android/withProjectStrings.d.ts +15 -0
- package/plugin/lib/typescript/helpers/constants/ios.d.ts +30 -0
- package/{lib → plugin/lib}/typescript/helpers/utils/codeInjection.d.ts +3 -1
- package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +4 -0
- package/{lib → plugin/lib}/typescript/types/cio-types.d.ts +8 -2
- package/{src → plugin/src}/android/withCIOAndroid.ts +2 -0
- package/plugin/src/android/withProjectStrings.ts +57 -0
- package/plugin/src/helpers/constants/ios.ts +144 -0
- package/plugin/src/helpers/native-files/ios/Env.swift +7 -0
- package/plugin/src/helpers/native-files/ios/NotificationService.swift +25 -0
- package/{lib/commonjs → plugin/src}/helpers/native-files/ios/PushService.swift +10 -13
- package/{src → plugin/src}/helpers/utils/codeInjection.ts +12 -1
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +67 -0
- package/plugin/src/helpers/utils/pluginUtils.ts +22 -0
- package/{src → plugin/src}/ios/withAppDelegateModifications.ts +118 -23
- package/{src → plugin/src}/ios/withNotificationsXcodeProject.ts +57 -35
- package/plugin/src/postInstallHelper.js +32 -0
- package/{src → plugin/src}/types/cio-types.ts +8 -2
- package/lib/commonjs/android/withCIOAndroid.js.map +0 -1
- package/lib/commonjs/helpers/constants/android.js +0 -21
- package/lib/commonjs/helpers/constants/ios.js +0 -121
- package/lib/commonjs/helpers/constants/ios.js.map +0 -1
- package/lib/commonjs/helpers/native-files/ios/Env.swift +0 -8
- package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +0 -22
- package/lib/commonjs/helpers/utils/codeInjection.js.map +0 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +0 -36
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +0 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +0 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +0 -1
- package/lib/commonjs/postInstallHelper.js +0 -20
- package/lib/commonjs/postInstallHelper.js.map +0 -1
- package/lib/commonjs/types/cio-types.js.map +0 -1
- package/lib/module/android/withCIOAndroid.js.map +0 -1
- package/lib/module/helpers/constants/ios.js +0 -84
- package/lib/module/helpers/constants/ios.js.map +0 -1
- package/lib/module/helpers/native-files/ios/Env.swift +0 -8
- package/lib/module/helpers/native-files/ios/NotificationService.swift +0 -22
- package/lib/module/helpers/utils/codeInjection.js.map +0 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +0 -29
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +0 -1
- package/lib/module/ios/withAppDelegateModifications.js +0 -82
- package/lib/module/ios/withAppDelegateModifications.js.map +0 -1
- package/lib/module/ios/withNotificationsXcodeProject.js.map +0 -1
- package/lib/module/postInstallHelper.js +0 -18
- package/lib/module/postInstallHelper.js.map +0 -1
- package/lib/module/types/cio-types.js.map +0 -1
- package/lib/typescript/helpers/constants/ios.d.ts +0 -31
- package/src/helpers/constants/ios.ts +0 -104
- package/src/helpers/native-files/ios/Env.swift +0 -8
- package/src/helpers/native-files/ios/NotificationService.swift +0 -22
- package/src/helpers/utils/injectCIOPodfileCode.ts +0 -54
- package/src/postInstallHelper.js +0 -22
- /package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/native-files/ios/NotificationService-Info.plist +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/native-files/ios/NotificationService.h +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/native-files/ios/NotificationService.m +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js +0 -0
- /package/{lib → plugin/lib}/commonjs/ios/withCIOIos.js +0 -0
- /package/{lib → plugin/lib}/commonjs/ios/withXcodeProject.js +0 -0
- /package/{lib → plugin/lib}/commonjs/postInstall.js +0 -0
- /package/{lib → plugin/lib}/commonjs/types/cio-types.js +0 -0
- /package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js +0 -0
- /package/{lib → plugin/lib}/module/android/withAppGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/module/android/withGistMavenRepository.js +0 -0
- /package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js +0 -0
- /package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/module/helpers/constants/android.js +0 -0
- /package/{lib → plugin/lib}/module/helpers/constants/globals.d.js +0 -0
- /package/{lib → plugin/lib}/module/helpers/native-files/ios/NotificationService-Info.plist +0 -0
- /package/{lib → plugin/lib}/module/helpers/native-files/ios/NotificationService.h +0 -0
- /package/{lib → plugin/lib}/module/helpers/native-files/ios/NotificationService.m +0 -0
- /package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js +0 -0
- /package/{lib → plugin/lib}/module/index.js +0 -0
- /package/{lib → plugin/lib}/module/ios/withCIOIos.js +0 -0
- /package/{lib → plugin/lib}/module/ios/withXcodeProject.js +0 -0
- /package/{lib → plugin/lib}/module/postInstall.js +0 -0
- /package/{lib → plugin/lib}/module/types/cio-types.js +0 -0
- /package/{lib → plugin/lib}/typescript/android/withAndroidManifestUpdates.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withAppGoogleServices.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withCIOAndroid.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withGistMavenRepository.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withGoogleServicesJSON.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withProjectGoogleServices.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/helpers/constants/android.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/helpers/utils/fileManagement.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/helpers/utils/injectCIOPodfileCode.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/index.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withAppDelegateModifications.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withCIOIos.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withNotificationsXcodeProject.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withXcodeProject.d.ts +0 -0
- /package/{src → plugin/src}/android/withAndroidManifestUpdates.ts +0 -0
- /package/{src → plugin/src}/android/withAppGoogleServices.ts +0 -0
- /package/{src → plugin/src}/android/withGistMavenRepository.ts +0 -0
- /package/{src → plugin/src}/android/withGoogleServicesJSON.ts +0 -0
- /package/{src → plugin/src}/android/withProjectGoogleServices.ts +0 -0
- /package/{src → plugin/src}/helpers/constants/android.ts +0 -0
- /package/{src → plugin/src}/helpers/constants/globals.d.ts +0 -0
- /package/{src → plugin/src}/helpers/native-files/ios/NotificationService-Info.plist +0 -0
- /package/{src → plugin/src}/helpers/native-files/ios/NotificationService.h +0 -0
- /package/{src → plugin/src}/helpers/native-files/ios/NotificationService.m +0 -0
- /package/{src → plugin/src}/helpers/utils/fileManagement.ts +0 -0
- /package/{src → plugin/src}/index.ts +0 -0
- /package/{src → plugin/src}/ios/withCIOIos.ts +0 -0
- /package/{src → plugin/src}/ios/withXcodeProject.ts +0 -0
- /package/{src → plugin/src}/postInstall.js +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { withAppDelegate } from '@expo/config-plugins';
|
|
2
|
+
import { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';
|
|
3
|
+
import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_IMPORT_SNIPPET, CIO_APPDELEGATEHEADER_REGEX, CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET, CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET, CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET, CIO_DEEPLINK_COMMENT_REGEX, CIO_INITIALIZECIOSDK_SNIPPET } from '../helpers/constants/ios';
|
|
4
|
+
import { injectCodeBeforeMultiLineRegex, injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine, replaceCodeByRegex, matchRegexExists } from '../helpers/utils/codeInjection';
|
|
5
|
+
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
6
|
+
const addImport = (stringContents, appName) => {
|
|
7
|
+
const importRegex = /^(#import .*)\n/gm;
|
|
8
|
+
const addedImport = getImportSnippet(appName);
|
|
9
|
+
const match = stringContents.match(importRegex);
|
|
10
|
+
let endOfMatchIndex;
|
|
11
|
+
if (!match || match.index === undefined) {
|
|
12
|
+
// No imports found, just add to start of file:
|
|
13
|
+
endOfMatchIndex = 0;
|
|
14
|
+
} else {
|
|
15
|
+
// Add after first import:
|
|
16
|
+
endOfMatchIndex = match.index + match[0].length;
|
|
17
|
+
}
|
|
18
|
+
stringContents = injectCodeByLineNumber(stringContents, endOfMatchIndex, addedImport);
|
|
19
|
+
return stringContents;
|
|
20
|
+
};
|
|
21
|
+
const addNotificationHandlerDeclaration = stringContents => {
|
|
22
|
+
stringContents = injectCodeByMultiLineRegex(stringContents, CIO_APPDELEGATEDECLARATION_REGEX, CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
|
|
23
|
+
return stringContents;
|
|
24
|
+
};
|
|
25
|
+
const addNotificationConfiguration = stringContents => {
|
|
26
|
+
stringContents = injectCodeBeforeMultiLineRegex(stringContents, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
|
|
27
|
+
return stringContents;
|
|
28
|
+
};
|
|
29
|
+
const addInitializeNativeCioSdk = stringContents => {
|
|
30
|
+
stringContents = injectCodeBeforeMultiLineRegex(stringContents, CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, CIO_INITIALIZECIOSDK_SNIPPET);
|
|
31
|
+
return stringContents;
|
|
32
|
+
};
|
|
33
|
+
const addHandleDeeplinkInKilledStateConfiguration = (stringContents, regex) => {
|
|
34
|
+
stringContents = injectCodeBeforeMultiLineRegex(stringContents, regex, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET);
|
|
35
|
+
return stringContents;
|
|
36
|
+
};
|
|
37
|
+
const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
|
|
38
|
+
stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
|
|
39
|
+
return stringContents;
|
|
40
|
+
};
|
|
41
|
+
const addDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
|
|
42
|
+
stringContents = injectCodeByMultiLineRegexAndReplaceLine(stringContents, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
|
|
43
|
+
return stringContents;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Adds required import for Expo Notifications package in AppDelegate.
|
|
47
|
+
// Required to call functions from the package.
|
|
48
|
+
const addExpoNotificationsHeaderModification = stringContents => {
|
|
49
|
+
stringContents = injectCodeByLineNumber(stringContents, 0, `
|
|
50
|
+
#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
51
|
+
#import <EXNotifications/EXNotificationCenterDelegate.h>
|
|
52
|
+
#endif
|
|
53
|
+
`);
|
|
54
|
+
return stringContents;
|
|
55
|
+
};
|
|
56
|
+
const addAppdelegateHeaderModification = stringContents => {
|
|
57
|
+
// Add UNUserNotificationCenterDelegate if needed
|
|
58
|
+
stringContents = stringContents.replace(CIO_APPDELEGATEHEADER_REGEX, (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
|
|
59
|
+
if (existingDelegates && existingDelegates.includes(CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET)) {
|
|
60
|
+
// The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it
|
|
61
|
+
return match;
|
|
62
|
+
} else if (existingDelegates) {
|
|
63
|
+
// Other delegates exist, append ours
|
|
64
|
+
return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}
|
|
65
|
+
${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>
|
|
66
|
+
`;
|
|
67
|
+
} else {
|
|
68
|
+
// No delegates exist, add ours
|
|
69
|
+
return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}
|
|
70
|
+
${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return stringContents;
|
|
75
|
+
};
|
|
76
|
+
const addHandleDeeplinkInKilledState = stringContents => {
|
|
77
|
+
// Find if the deep link code snippet is already present
|
|
78
|
+
if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {
|
|
79
|
+
return stringContents;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Check if the app delegate is using RCTBridge or LaunchOptions
|
|
83
|
+
let snippet = undefined;
|
|
84
|
+
let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
85
|
+
if (matchRegexExists(stringContents, CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
86
|
+
snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;
|
|
87
|
+
regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
88
|
+
} else if (matchRegexExists(stringContents, CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
89
|
+
snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;
|
|
90
|
+
}
|
|
91
|
+
// Add code only if the app delegate is using RCTBridge or LaunchOptions
|
|
92
|
+
if (snippet !== undefined) {
|
|
93
|
+
stringContents = addHandleDeeplinkInKilledStateConfiguration(stringContents, regex);
|
|
94
|
+
stringContents = replaceCodeByRegex(stringContents, regex, snippet);
|
|
95
|
+
}
|
|
96
|
+
return stringContents;
|
|
97
|
+
};
|
|
98
|
+
export const withAppDelegateModifications = (configOuter, props) => {
|
|
99
|
+
return withAppDelegate(configOuter, async config => {
|
|
100
|
+
let stringContents = config.modResults.contents;
|
|
101
|
+
const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
|
|
102
|
+
const match = stringContents.match(regex);
|
|
103
|
+
if (!match) {
|
|
104
|
+
const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
|
|
105
|
+
let headerContent = await FileManagement.read(headerPath);
|
|
106
|
+
headerContent = addAppdelegateHeaderModification(headerContent);
|
|
107
|
+
FileManagement.write(headerPath, headerContent);
|
|
108
|
+
stringContents = addImport(stringContents, config.modRequest.projectName);
|
|
109
|
+
stringContents = addNotificationHandlerDeclaration(stringContents);
|
|
110
|
+
|
|
111
|
+
// any other value would be treated as true, it has to be explicitly false to disable
|
|
112
|
+
if (props.disableNotificationRegistration !== undefined && props.disableNotificationRegistration === false) {
|
|
113
|
+
stringContents = addNotificationConfiguration(stringContents);
|
|
114
|
+
}
|
|
115
|
+
stringContents = addInitializeNativeCioSdk(stringContents);
|
|
116
|
+
if (props.handleDeeplinkInKilledState !== undefined && props.handleDeeplinkInKilledState === true) {
|
|
117
|
+
stringContents = addHandleDeeplinkInKilledState(stringContents);
|
|
118
|
+
}
|
|
119
|
+
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
120
|
+
stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
121
|
+
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
122
|
+
config.modResults.contents = stringContents;
|
|
123
|
+
} else {
|
|
124
|
+
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
125
|
+
}
|
|
126
|
+
return config;
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
function getImportSnippet(appName) {
|
|
130
|
+
return `
|
|
131
|
+
// Add swift bridge imports
|
|
132
|
+
#import <ExpoModulesCore-Swift.h>
|
|
133
|
+
#import <${appName}-Swift.h>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=withAppDelegateModifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_DEEPLINK_COMMENT_REGEX","CIO_INITIALIZECIOSDK_SNIPPET","injectCodeBeforeMultiLineRegex","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","replaceCodeByRegex","matchRegexExists","FileManagement","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addInitializeNativeCioSdk","addHandleDeeplinkInKilledStateConfiguration","regex","addDidFailToRegisterForRemoteNotificationsWithError","addDidRegisterForRemoteNotificationsWithDeviceToken","addExpoNotificationsHeaderModification","addAppdelegateHeaderModification","replace","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","trim","addHandleDeeplinkInKilledState","snippet","withAppDelegateModifications","configOuter","props","config","modResults","contents","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","disableNotificationRegistration","handleDeeplinkInKilledState","console","log"],"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,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,oCAAoC,EACpCC,2BAA2B,EAC3BC,sDAAsD,EACtDC,2CAA2C,EAC3CC,yCAAyC,EACzCC,4CAA4C,EAC5CC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,0DAA0D,EAC1D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,GAAGpB,gCAAgC,CAACoB,aAAa,CAAC;MAC/DxC,cAAc,CAAC0C,KAAK,CAACJ,UAAU,EAAEE,aAAa,CAAC;MAE/CtC,cAAc,GAAGD,SAAS,CACxBC,cAAc,EACd8B,MAAM,CAACI,UAAU,CAACC,WACpB,CAAC;MACDnC,cAAc,GAAGU,iCAAiC,CAACV,cAAc,CAAC;;MAElE;MACA,IACE6B,KAAK,CAACY,+BAA+B,KAAKjC,SAAS,IACnDqB,KAAK,CAACY,+BAA+B,KAAK,KAAK,EAC/C;QACAzC,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC/D;MAEAA,cAAc,GAAGY,yBAAyB,CAACZ,cAAc,CAAC;MAE1D,IACE6B,KAAK,CAACa,2BAA2B,KAAKlC,SAAS,IAC/CqB,KAAK,CAACa,2BAA2B,KAAK,IAAI,EAC1C;QACA1C,cAAc,GAAGyB,8BAA8B,CAACzB,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZe,mDAAmD,CAACf,cAAc,CAAC;MACrEA,cAAc,GACZgB,mDAAmD,CAAChB,cAAc,CAAC;MAErEA,cAAc,GAAGiB,sCAAsC,CAACjB,cAAc,CAAC;MAEvE8B,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGhC,cAAc;IAC7C,CAAC,MAAM;MACL2C,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOd,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAAS1B,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGJ,4BAA4B,CAACI,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC7C;EAEA,OAAOD,MAAM;AACf"}
|
|
1
|
+
{"version":3,"names":["withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAUA,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGJ,4BAA4B,CAACI,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC7C;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { withXcodeProject } from '@expo/config-plugins';
|
|
2
|
-
import xcode from 'xcode';
|
|
3
2
|
import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
|
|
4
3
|
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
5
4
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
@@ -7,28 +6,20 @@ import { FileManagement } from './../helpers/utils/fileManagement';
|
|
|
7
6
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
8
7
|
const ENV_FILENAME = 'Env.swift';
|
|
9
8
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
10
|
-
const addNotificationServiceExtension = async options => {
|
|
11
|
-
|
|
12
|
-
// See function withCioNotificationsXcodeProject to get where the variabes are pulled from.
|
|
13
|
-
const {
|
|
14
|
-
iosPath,
|
|
15
|
-
appName
|
|
16
|
-
} = options;
|
|
17
|
-
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
18
|
-
const xcodeProject = xcode.project(projPath);
|
|
19
|
-
xcodeProject.parse(async function (err) {
|
|
9
|
+
const addNotificationServiceExtension = async (options, xcodeProject) => {
|
|
10
|
+
try {
|
|
20
11
|
var _options$pushNotifica;
|
|
21
|
-
if (err) {
|
|
22
|
-
throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
|
|
23
|
-
}
|
|
24
12
|
if (options.pushNotification) {
|
|
25
13
|
await addPushNotificationFile(options, xcodeProject);
|
|
26
14
|
}
|
|
27
15
|
if ((_options$pushNotifica = options.pushNotification) !== null && _options$pushNotifica !== void 0 && _options$pushNotifica.useRichPush) {
|
|
28
16
|
await addRichPushXcodeProj(options, xcodeProject);
|
|
29
17
|
}
|
|
30
|
-
|
|
31
|
-
})
|
|
18
|
+
return xcodeProject;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
32
23
|
};
|
|
33
24
|
export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
34
25
|
return withXcodeProject(configOuter, async config => {
|
|
@@ -75,7 +66,10 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
75
66
|
iosDeploymentTarget,
|
|
76
67
|
pushNotification
|
|
77
68
|
};
|
|
78
|
-
await addNotificationServiceExtension(options);
|
|
69
|
+
const modifiedProjectFile = await addNotificationServiceExtension(options, config.modResults);
|
|
70
|
+
if (modifiedProjectFile) {
|
|
71
|
+
config.modResults = modifiedProjectFile;
|
|
72
|
+
}
|
|
79
73
|
return config;
|
|
80
74
|
});
|
|
81
75
|
};
|
|
@@ -156,7 +150,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
156
150
|
if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${CIO_NOTIFICATION_TARGET_NAME}"`) {
|
|
157
151
|
const buildSettingsObj = configurations[key].buildSettings;
|
|
158
152
|
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
159
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '
|
|
153
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '15.1';
|
|
160
154
|
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
161
155
|
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
162
156
|
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
@@ -180,30 +174,25 @@ const updateNseInfoPlist = payload => {
|
|
|
180
174
|
FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
|
|
181
175
|
};
|
|
182
176
|
const updateNseEnv = (options, envFileName) => {
|
|
183
|
-
var _options$pushNotifica2, _options$
|
|
184
|
-
const
|
|
185
|
-
const API_KEY_RE = /\{\{API_KEY\}\}/;
|
|
177
|
+
var _options$pushNotifica2, _options$pushNotifica4;
|
|
178
|
+
const CDP_API_KEY_RE = /\{\{CDP_API_KEY\}\}/;
|
|
186
179
|
const REGION_RE = /\{\{REGION\}\}/;
|
|
187
180
|
let envFileContent = FileManagement.readFile(envFileName);
|
|
188
|
-
if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$
|
|
189
|
-
var _options$
|
|
190
|
-
envFileContent = replaceCodeByRegex(envFileContent,
|
|
181
|
+
if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$pushNotifica2 = _options$pushNotifica2.env) !== null && _options$pushNotifica2 !== void 0 && _options$pushNotifica2.cdpApiKey) {
|
|
182
|
+
var _options$pushNotifica3;
|
|
183
|
+
envFileContent = replaceCodeByRegex(envFileContent, CDP_API_KEY_RE, (_options$pushNotifica3 = options.pushNotification) === null || _options$pushNotifica3 === void 0 || (_options$pushNotifica3 = _options$pushNotifica3.env) === null || _options$pushNotifica3 === void 0 ? void 0 : _options$pushNotifica3.cdpApiKey);
|
|
191
184
|
}
|
|
192
|
-
if ((_options$
|
|
193
|
-
var _options$
|
|
194
|
-
envFileContent = replaceCodeByRegex(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
|
|
195
|
-
}
|
|
196
|
-
if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
|
|
197
|
-
var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14;
|
|
185
|
+
if ((_options$pushNotifica4 = options.pushNotification) !== null && _options$pushNotifica4 !== void 0 && (_options$pushNotifica4 = _options$pushNotifica4.env) !== null && _options$pushNotifica4 !== void 0 && _options$pushNotifica4.region) {
|
|
186
|
+
var _options$pushNotifica5;
|
|
198
187
|
const regionMap = {
|
|
199
188
|
us: 'Region.US',
|
|
200
189
|
eu: 'Region.EU'
|
|
201
190
|
};
|
|
202
|
-
const region = (_options$
|
|
191
|
+
const region = (_options$pushNotifica5 = options.pushNotification) === null || _options$pushNotifica5 === void 0 || (_options$pushNotifica5 = _options$pushNotifica5.env) === null || _options$pushNotifica5 === void 0 || (_options$pushNotifica5 = _options$pushNotifica5.region) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.toLowerCase();
|
|
203
192
|
const mappedRegion = regionMap[region] || '';
|
|
204
193
|
if (!mappedRegion) {
|
|
205
|
-
var _options$
|
|
206
|
-
console.warn(`${(_options$
|
|
194
|
+
var _options$pushNotifica6;
|
|
195
|
+
console.warn(`${(_options$pushNotifica6 = options.pushNotification) === null || _options$pushNotifica6 === void 0 || (_options$pushNotifica6 = _options$pushNotifica6.env) === null || _options$pushNotifica6 === void 0 ? void 0 : _options$pushNotifica6.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
|
|
207
196
|
} else {
|
|
208
197
|
envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
|
|
209
198
|
}
|
|
@@ -247,6 +236,14 @@ const updatePushFile = (options, envFileName) => {
|
|
|
247
236
|
snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;
|
|
248
237
|
}
|
|
249
238
|
envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);
|
|
239
|
+
if (options.pushNotification) {
|
|
240
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{CDP_API_KEY\}\}/, options.pushNotification.env.cdpApiKey);
|
|
241
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{REGION\}\}/, options.pushNotification.env.region.toUpperCase());
|
|
242
|
+
}
|
|
243
|
+
const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
|
|
244
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
245
|
+
const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
|
|
246
|
+
envFileContent = replaceCodeByRegex(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
250
247
|
FileManagement.writeFile(envFileName, envFileContent);
|
|
251
248
|
};
|
|
252
249
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withXcodeProject","CIO_NOTIFICATION_TARGET_NAME","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","xcodeProject","_options$pushNotifica","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","error","console","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","Error","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","iosPath","appName","modifiedProjectFile","modResults","pbxTargetByName","warn","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","project","objects","Object","keys","key","name","path","addToPbxGroup","uuid","projObjects","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","writeFile","envFileName","_options$pushNotifica2","_options$pushNotifica4","CDP_API_KEY_RE","REGION_RE","envFileContent","env","cdpApiKey","_options$pushNotifica3","region","_options$pushNotifica5","regionMap","us","eu","toLowerCase","mappedRegion","_options$pushNotifica6","file","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","REGISTER_RE","snippet","disableNotificationRegistration","toUpperCase","autoTrackPushEvents","toString","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import {\n ConfigPlugin,\n XcodeProject,\n withXcodeProject,\n} from '@expo/config-plugins';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: XcodeProject\n) => {\n try {\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n return xcodeProject;\n } catch (error: any) {\n console.error(error);\n return null;\n }\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n ...props,\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults\n );\n\n if (modifiedProjectFile) {\n config.modResults = modifiedProjectFile;\n }\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '15.1';\n buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;\n buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';\n buildSettingsObj.SWIFT_VERSION = 4.2;\n }\n }\n\n // Add development team to the target & the main\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);\n xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);\n};\n\nconst updateNseInfoPlist = (payload: {\n bundleVersion?: string;\n bundleShortVersion?: string;\n infoPlistTargetFile: string;\n}) => {\n const BUNDLE_SHORT_VERSION_RE = /\\{\\{BUNDLE_SHORT_VERSION\\}\\}/;\n const BUNDLE_VERSION_RE = /\\{\\{BUNDLE_VERSION\\}\\}/;\n\n let plistFileString = FileManagement.readFile(payload.infoPlistTargetFile);\n\n if (payload.bundleVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_VERSION_RE,\n payload.bundleVersion\n );\n }\n\n if (payload.bundleShortVersion) {\n plistFileString = replaceCodeByRegex(\n plistFileString,\n BUNDLE_SHORT_VERSION_RE,\n payload.bundleShortVersion\n );\n }\n\n FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);\n};\n\nconst updateNseEnv = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const CDP_API_KEY_RE = /\\{\\{CDP_API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.cdpApiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n options.pushNotification?.env?.cdpApiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(file);\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n return;\n }\n\n updatePushFile(options, targetFile);\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${file}`, null, group);\n}\n\nconst updatePushFile = (\n options: CustomerIOPluginOptionsIOS,\n envFileName: string\n) => {\n const REGISTER_RE = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n let snippet = '';\n if (\n options.disableNotificationRegistration !== undefined &&\n options.disableNotificationRegistration === false\n ) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n if (options.pushNotification) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n options.pushNotification.env.cdpApiKey\n );\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n options.pushNotification.env.region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.autoTrackPushEvents === undefined ||\n options.autoTrackPushEvents === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const showPushAppInForeground =\n options.showPushAppInForeground === undefined ||\n options.showPushAppInForeground === true;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AAAA,SAGEA,gBAAgB,QACX,sBAAsB;AAE7B,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAG,GAAGP,4BAA4B,aAAa;AACnE,MAAMQ,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAG,OAAO;AAEtC,MAAMC,+BAA+B,GAAG,MAAAA,CACtCC,OAAmC,EACnCC,YAA0B,KACvB;EACH,IAAI;IAAA,IAAAC,qBAAA;IACF,IAAIF,OAAO,CAACG,gBAAgB,EAAE;MAC5B,MAAMC,uBAAuB,CAACJ,OAAO,EAAEC,YAAY,CAAC;IACtD;IAEA,KAAAC,qBAAA,GAAIF,OAAO,CAACG,gBAAgB,cAAAD,qBAAA,eAAxBA,qBAAA,CAA0BG,WAAW,EAAE;MACzC,MAAMC,oBAAoB,CAACN,OAAO,EAAEC,YAAY,CAAC;IACnD;IACA,OAAOA,YAAY;EACrB,CAAC,CAAC,OAAOM,KAAU,EAAE;IACnBC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;IACpB,OAAO,IAAI;EACb;AACF,CAAC;AAED,OAAO,MAAME,gCAEZ,GAAGA,CAACC,WAAW,EAAEC,KAAK,KAAK;EAC1B,OAAOvB,gBAAgB,CAACsB,WAAW,EAAE,MAAOE,MAAM,IAAK;IACrD,MAAM;MAAEC,UAAU;MAAEC,GAAG;MAAE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pB,OAAO,CAAC+G,uBAAuB,KAAK,IAAI;EAC1C5B,cAAc,GAAG1F,kBAAkB,CACjC0F,cAAc,EACd,qCAAqC,EACrC4B,uBAAuB,CAACD,QAAQ,CAAC,CACnC,CAAC;EAEDnH,cAAc,CAACkF,SAAS,CAACC,WAAW,EAAEK,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOJ,gBAAgB,CAACG,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,GAAAN,UAAA,GAAED,KAAK,CAACQ,GAAG,cAAAP,UAAA,uBAATA,UAAA,CAAWM,gBAAgB;MAC7CE,OAAO,EAAEV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO;MAC1BC,aAAa,GAAAR,WAAA,GAAEF,KAAK,CAACQ,GAAG,cAAAN,WAAA,uBAATA,WAAA,CAAWS,WAAW;MACrCC,kBAAkB,EAAEZ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEa,OAAO;MAClCC,mBAAmB,EAAEf,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEe;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAMP,oBAAoB,CAACQ,OAAO,CAAC;IAEnC,OAAOJ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"names":["withXcodeProject","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","_props$ios","_props$ios2","options","iosPath","modRequest","platformProjectRoot","bundleIdentifier","ios","devTeam","bundleVersion","buildNumber","bundleShortVersion","version","iosDeploymentTarget"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\n\nimport { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nexport const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n config,\n cioProps\n) => {\n return withXcodeProject(config, async (props) => {\n const options: CustomerIOPluginOptionsIOS = {\n iosPath: props.modRequest.platformProjectRoot,\n bundleIdentifier: props.ios?.bundleIdentifier,\n devTeam: cioProps?.devTeam,\n bundleVersion: props.ios?.buildNumber,\n bundleShortVersion: props?.version,\n iosDeploymentTarget: cioProps?.iosDeploymentTarget,\n };\n const { iosPath } = options;\n\n await injectCIOPodfileCode(iosPath);\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AAErE,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOJ,gBAAgB,CAACG,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAC/C,MAAMC,OAAmC,GAAG;MAC1CC,OAAO,EAAEJ,KAAK,CAACK,UAAU,CAACC,mBAAmB;MAC7CC,gBAAgB,GAAAN,UAAA,GAAED,KAAK,CAACQ,GAAG,cAAAP,UAAA,uBAATA,UAAA,CAAWM,gBAAgB;MAC7CE,OAAO,EAAEV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO;MAC1BC,aAAa,GAAAR,WAAA,GAAEF,KAAK,CAACQ,GAAG,cAAAN,WAAA,uBAATA,WAAA,CAAWS,WAAW;MACrCC,kBAAkB,EAAEZ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEa,OAAO;MAClCC,mBAAmB,EAAEf,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEe;IACjC,CAAC;IACD,MAAM;MAAEV;IAAQ,CAAC,GAAGD,OAAO;IAE3B,MAAMP,oBAAoB,CAACQ,OAAO,CAAC;IAEnC,OAAOJ,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,CAAC,CAAC;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":"AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,CAAC,CAAC;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
function runPostInstall() {
|
|
3
|
+
// react native SDK package.json path
|
|
4
|
+
const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;
|
|
5
|
+
const expoPackageJsonFile = `${__dirname}/../../package.json`;
|
|
6
|
+
try {
|
|
7
|
+
// if react native SDK is installed
|
|
8
|
+
if (fs.existsSync(reactNativePackageJsonFile)) {
|
|
9
|
+
const reactNativePackageJson = fs.readFileSync(reactNativePackageJsonFile, 'utf8');
|
|
10
|
+
const expoPackageJson = require(expoPackageJsonFile);
|
|
11
|
+
const reactNativePackage = JSON.parse(reactNativePackageJson);
|
|
12
|
+
reactNativePackage.expoVersion = expoPackageJson.version;
|
|
13
|
+
fs.writeFileSync(reactNativePackageJsonFile, JSON.stringify(reactNativePackage, null, 2));
|
|
14
|
+
}
|
|
15
|
+
} catch (error) {
|
|
16
|
+
console.warn('Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.', error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.runPostInstall = runPostInstall;
|
|
20
|
+
//# sourceMappingURL=postInstallHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","require","runPostInstall","reactNativePackageJsonFile","__dirname","expoPackageJsonFile","existsSync","reactNativePackageJson","readFileSync","expoPackageJson","reactNativePackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","console","warn","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const reactNativePackageJsonFile = `${__dirname}/../../../customerio-reactnative/package.json`;\n const expoPackageJsonFile = `${__dirname}/../../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(reactNativePackageJsonFile)) {\n const reactNativePackageJson = fs.readFileSync(\n reactNativePackageJsonFile,\n 'utf8'\n );\n const expoPackageJson = require(expoPackageJsonFile);\n\n const reactNativePackage = JSON.parse(reactNativePackageJson);\n reactNativePackage.expoVersion = expoPackageJson.version;\n\n fs.writeFileSync(\n reactNativePackageJsonFile,\n JSON.stringify(reactNativePackage, null, 2)\n );\n }\n } catch (error) {\n console.warn(\n 'Unable to find customerio-reactnative package.json file. Please make sure you have installed the customerio-reactnative package.',\n error\n );\n }\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":"AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAcA,CAAA,EAAG;EACxB;EACA,MAAMC,0BAA0B,GAAG,GAAGC,SAAS,+CAA+C;EAC9F,MAAMC,mBAAmB,GAAG,GAAGD,SAAS,qBAAqB;EAC7D,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,0BAA0B,CAAC,EAAE;MAC7C,MAAMI,sBAAsB,GAAGP,EAAE,CAACQ,YAAY,CAC5CL,0BAA0B,EAC1B,MACF,CAAC;MACD,MAAMM,eAAe,GAAGR,OAAO,CAACI,mBAAmB,CAAC;MAEpD,MAAMK,kBAAkB,GAAGC,IAAI,CAACC,KAAK,CAACL,sBAAsB,CAAC;MAC7DG,kBAAkB,CAACG,WAAW,GAAGJ,eAAe,CAACK,OAAO;MAExDd,EAAE,CAACe,aAAa,CACdZ,0BAA0B,EAC1BQ,IAAI,CAACK,SAAS,CAACN,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAC5C,CAAC;IACH;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdC,OAAO,CAACC,IAAI,CACV,kIAAkI,EAClIF,KACF,CAAC;EACH;AACF;AAEAG,OAAO,CAAClB,cAAc,GAAGA,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n disableNotificationRegistration?: boolean;\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n showPushAppInForeground?: boolean;\n autoTrackPushEvents?: boolean;\n handleDeeplinkInKilledState?: boolean;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n cdpApiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* Adds or updates string resources in Android's strings.xml required by the plugin
|
|
4
|
+
*/
|
|
5
|
+
export declare const withProjectStrings: ConfigPlugin;
|
|
6
|
+
/**
|
|
7
|
+
* Adds or updates multiple string resources in Android's strings.xml
|
|
8
|
+
* @param stringsXml - Parsed strings.xml object
|
|
9
|
+
* @param stringResources - Array of string resources to add or update
|
|
10
|
+
* @returns Updated strings.xml object
|
|
11
|
+
*/
|
|
12
|
+
export declare function addStringsToXml(stringsXml: any, stringResources: {
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}[]): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const LOCAL_PATH_TO_CIO_NSE_FILES: any;
|
|
2
|
+
export declare function getRelativePathToRNSDK(iosPath: string): any;
|
|
3
|
+
export declare const IOS_DEPLOYMENT_TARGET = "13.0";
|
|
4
|
+
export declare const GROUP_IDENTIFIER_TEMPLATE_REGEX: RegExp;
|
|
5
|
+
export declare const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX: RegExp;
|
|
6
|
+
export declare const BUNDLE_VERSION_TEMPLATE_REGEX: RegExp;
|
|
7
|
+
export declare const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX: RegExp;
|
|
8
|
+
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX: RegExp;
|
|
9
|
+
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX: RegExp;
|
|
10
|
+
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX: RegExp;
|
|
11
|
+
export declare const CIO_APPDELEGATEDECLARATION_REGEX: RegExp;
|
|
12
|
+
export declare const CIO_APPDELEGATEHEADER_REGEX: RegExp;
|
|
13
|
+
export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
|
|
14
|
+
export declare const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX: RegExp;
|
|
15
|
+
export declare const CIO_DEEPLINK_COMMENT_REGEX: RegExp;
|
|
16
|
+
export declare const DEFAULT_BUNDLE_VERSION = "1";
|
|
17
|
+
export declare const DEFAULT_BUNDLE_SHORT_VERSION = "1.0";
|
|
18
|
+
export declare const CIO_TARGET_NAME = "CustomerIOSDK";
|
|
19
|
+
export declare const CIO_NOTIFICATION_TARGET_NAME = "NotificationService";
|
|
20
|
+
export declare const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = "#import <UserNotifications/UserNotifications.h>";
|
|
21
|
+
export declare const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = "UNUserNotificationCenterDelegate";
|
|
22
|
+
export declare const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = "\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n";
|
|
23
|
+
export declare const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = "\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n";
|
|
24
|
+
export declare const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = "\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];";
|
|
25
|
+
export declare const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = "\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n";
|
|
26
|
+
export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = "\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n";
|
|
27
|
+
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n";
|
|
28
|
+
export declare 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";
|
|
29
|
+
export declare 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";
|
|
30
|
+
export declare 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 }";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function injectCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string[];
|
|
2
2
|
export declare function injectCodeByMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
|
+
export declare function injectCodeBeforeMultiLineRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
3
4
|
export declare function replaceCodeByRegex(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
5
|
+
export declare function matchRegexExists(fileContent: string, regex: RegExp): boolean;
|
|
4
6
|
export declare function injectCodeByMultiLineRegexAndReplaceLine(fileContent: string, lineRegex: RegExp, snippet: string): string;
|
|
5
|
-
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string
|
|
7
|
+
export declare function injectCodeByLineNumber(fileContent: string, index: number, snippet: string): string;
|
|
@@ -12,12 +12,18 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
12
12
|
appleTeamId?: string;
|
|
13
13
|
appName?: string;
|
|
14
14
|
disableNotificationRegistration?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.
|
|
17
|
+
*/
|
|
18
|
+
handleNotificationClick?: boolean;
|
|
19
|
+
showPushAppInForeground?: boolean;
|
|
20
|
+
autoTrackPushEvents?: boolean;
|
|
21
|
+
handleDeeplinkInKilledState?: boolean;
|
|
15
22
|
useFrameworks?: 'static' | 'dynamic';
|
|
16
23
|
pushNotification?: {
|
|
17
24
|
useRichPush: boolean;
|
|
18
25
|
env: {
|
|
19
|
-
|
|
20
|
-
apiKey: string;
|
|
26
|
+
cdpApiKey: string;
|
|
21
27
|
region: string;
|
|
22
28
|
};
|
|
23
29
|
};
|
|
@@ -6,6 +6,7 @@ import { withAppGoogleServices } from './withAppGoogleServices';
|
|
|
6
6
|
import { withGistMavenRepository } from './withGistMavenRepository';
|
|
7
7
|
import { withGoogleServicesJSON } from './withGoogleServicesJSON';
|
|
8
8
|
import { withProjectGoogleServices } from './withProjectGoogleServices';
|
|
9
|
+
import { withProjectStrings } from './withProjectStrings';
|
|
9
10
|
|
|
10
11
|
export function withCIOAndroid(
|
|
11
12
|
config: ExpoConfig,
|
|
@@ -15,6 +16,7 @@ export function withCIOAndroid(
|
|
|
15
16
|
config = withProjectGoogleServices(config, props);
|
|
16
17
|
config = withAppGoogleServices(config, props);
|
|
17
18
|
config = withGoogleServicesJSON(config, props);
|
|
19
|
+
config = withProjectStrings(config);
|
|
18
20
|
if (props.setHighPriorityPushHandler) {
|
|
19
21
|
config = withAndroidManifestUpdates(config, props);
|
|
20
22
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ConfigPlugin, withStringsXml } from '@expo/config-plugins';
|
|
2
|
+
import { getPluginVersion } from '../helpers/utils/pluginUtils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Adds or updates string resources in Android's strings.xml required by the plugin
|
|
6
|
+
*/
|
|
7
|
+
export const withProjectStrings: ConfigPlugin = (config) => {
|
|
8
|
+
return withStringsXml(config, (config) => {
|
|
9
|
+
const stringsXml = config.modResults;
|
|
10
|
+
const pluginVersion = getPluginVersion();
|
|
11
|
+
|
|
12
|
+
// Updating meta-data in AndroidManifest.xml fails on Manifest merging, so we're updating
|
|
13
|
+
// the strings here instead
|
|
14
|
+
// These strings are added to the strings.xml file by Customer.io's React Native SDK
|
|
15
|
+
// We're updating them here to include the Expo client source and version so user agent
|
|
16
|
+
// can be generated correctly for Expo apps
|
|
17
|
+
addStringsToXml(stringsXml, [
|
|
18
|
+
{ name: 'customer_io_react_native_sdk_client_source', value: 'Expo' },
|
|
19
|
+
{ name: 'customer_io_react_native_sdk_client_version', value: pluginVersion },
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
return config;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Adds or updates multiple string resources in Android's strings.xml
|
|
28
|
+
* @param stringsXml - Parsed strings.xml object
|
|
29
|
+
* @param stringResources - Array of string resources to add or update
|
|
30
|
+
* @returns Updated strings.xml object
|
|
31
|
+
*/
|
|
32
|
+
export function addStringsToXml(
|
|
33
|
+
stringsXml: any,
|
|
34
|
+
stringResources: { name: string, value: string }[]
|
|
35
|
+
) {
|
|
36
|
+
// Ensure the resource exists
|
|
37
|
+
if (!stringsXml.resources) {
|
|
38
|
+
stringsXml.resources = { string: [] };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stringResources.forEach(({ name, value }) => {
|
|
42
|
+
const existingStringIndex = stringsXml.resources.string.findIndex(
|
|
43
|
+
(item: { $: { name: string } }) => item.$?.name === name
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (existingStringIndex !== -1) {
|
|
47
|
+
// Update the existing string
|
|
48
|
+
stringsXml.resources.string[existingStringIndex]._ = value;
|
|
49
|
+
} else {
|
|
50
|
+
// Add a new string resource
|
|
51
|
+
stringsXml.resources.string.push({
|
|
52
|
+
$: { name },
|
|
53
|
+
_: value,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|