customerio-expo-plugin 2.0.2 → 2.1.0
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/package.json +10 -10
- package/plugin/lib/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/ios.js +27 -1
- package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +52 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +74 -0
- package/plugin/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +17 -2
- package/plugin/lib/commonjs/ios/utils.js.map +1 -1
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +8 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +269 -0
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +4 -3
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/plugin/lib/module/android/withAppGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withGistMavenRepository.js.map +1 -1
- package/plugin/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/plugin/lib/module/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withProjectStrings.js.map +1 -1
- package/plugin/lib/module/helpers/constants/ios.js +26 -0
- package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +52 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +74 -0
- package/plugin/lib/module/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +15 -1
- package/plugin/lib/module/ios/utils.js.map +1 -1
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +8 -1
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +262 -0
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +5 -4
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/typescript/android/withAndroidManifestUpdates.d.ts +1 -1
- package/plugin/lib/typescript/android/withAppGoogleServices.d.ts +1 -1
- package/plugin/lib/typescript/android/withGistMavenRepository.d.ts +1 -1
- package/plugin/lib/typescript/android/withGoogleServicesJSON.d.ts +1 -1
- package/plugin/lib/typescript/android/withProjectGoogleServices.d.ts +1 -1
- package/plugin/lib/typescript/android/withProjectStrings.d.ts +1 -1
- package/plugin/lib/typescript/helpers/constants/ios.d.ts +3 -0
- package/plugin/lib/typescript/helpers/utils/fileManagement.d.ts +1 -2
- package/plugin/lib/typescript/ios/utils.d.ts +2 -0
- package/plugin/lib/typescript/ios/withAppDelegateModifications.d.ts +1 -1
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +3 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +1 -1
- package/plugin/lib/typescript/ios/withNotificationsXcodeProject.d.ts +1 -1
- package/plugin/lib/typescript/ios/withXcodeProject.d.ts +1 -1
- package/plugin/src/android/withAndroidManifestUpdates.ts +2 -1
- package/plugin/src/android/withAppGoogleServices.ts +2 -1
- package/plugin/src/android/withGistMavenRepository.ts +2 -1
- package/plugin/src/android/withGoogleServicesJSON.ts +2 -1
- package/plugin/src/android/withProjectGoogleServices.ts +2 -1
- package/plugin/src/android/withProjectStrings.ts +2 -1
- package/plugin/src/helpers/constants/ios.ts +29 -0
- package/plugin/src/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +52 -0
- package/plugin/src/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +74 -0
- package/plugin/src/helpers/utils/fileManagement.ts +1 -1
- package/plugin/src/ios/utils.ts +20 -3
- package/plugin/src/ios/withAppDelegateModifications.ts +2 -1
- package/plugin/src/ios/withCIOIos.ts +15 -2
- package/plugin/src/ios/withCIOIosSwift.ts +384 -0
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +1 -1
- package/plugin/src/ios/withNotificationsXcodeProject.ts +9 -9
- package/plugin/src/ios/withXcodeProject.ts +2 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { withAppDelegate, withXcodeProject } from '@expo/config-plugins';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { FileManagement } from '../helpers/utils/fileManagement';
|
|
4
|
+
import { LOCAL_PATH_TO_CIO_NSE_FILES, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2, CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER, CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET } from '../helpers/constants/ios';
|
|
5
|
+
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
6
|
+
import { isFcmPushProvider } from './utils';
|
|
7
|
+
|
|
8
|
+
// Constants
|
|
9
|
+
const CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';
|
|
10
|
+
const CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copy and configure the CioSdkAppDelegateHandler.swift file
|
|
14
|
+
*/
|
|
15
|
+
const copyAndConfigureAppDelegateHandler = (config, props) => {
|
|
16
|
+
var _props$pushNotificati, _props$pushNotificati2, _props$pushNotificati3, _props$pushNotificati4;
|
|
17
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
18
|
+
const iosProjectRoot = path.join(projectRoot, 'ios');
|
|
19
|
+
const useFcm = isFcmPushProvider(props);
|
|
20
|
+
|
|
21
|
+
// Source path for the handler file
|
|
22
|
+
const handlerSourcePath = path.join(LOCAL_PATH_TO_CIO_NSE_FILES, useFcm ? 'fcm' : 'apn', CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
|
|
23
|
+
|
|
24
|
+
// Destination path in the iOS project
|
|
25
|
+
const projectName = config.modRequest.projectName || '';
|
|
26
|
+
if (!projectName) {
|
|
27
|
+
console.warn('Project name is undefined, cannot copy CioSdkAppDelegateHandler.swift');
|
|
28
|
+
return config;
|
|
29
|
+
}
|
|
30
|
+
const handlerDestPath = path.join(iosProjectRoot, projectName, CIO_SDK_APP_DELEGATE_HANDLER_FILENAME);
|
|
31
|
+
FileManagement.copyFile(handlerSourcePath, handlerDestPath);
|
|
32
|
+
|
|
33
|
+
// Add the file to the Xcode project
|
|
34
|
+
const xcodeProject = config.modResults;
|
|
35
|
+
|
|
36
|
+
// Create a group for CustomerIO files if it doesn't exist
|
|
37
|
+
let group;
|
|
38
|
+
const existingGroup = xcodeProject.pbxGroupByName('CustomerIO');
|
|
39
|
+
if (existingGroup) {
|
|
40
|
+
group = existingGroup;
|
|
41
|
+
} else {
|
|
42
|
+
group = xcodeProject.pbxCreateGroup('CustomerIO');
|
|
43
|
+
const classesKey = xcodeProject.findPBXGroupKey({
|
|
44
|
+
name: projectName
|
|
45
|
+
});
|
|
46
|
+
xcodeProject.addToPbxGroup(group, classesKey);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Add the file to the Xcode project
|
|
50
|
+
xcodeProject.addSourceFile(`${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`, null, group);
|
|
51
|
+
let handlerFileContent = FileManagement.readFile(handlerDestPath);
|
|
52
|
+
const disableNotificationRegistration = (_props$pushNotificati = props.pushNotification) === null || _props$pushNotificati === void 0 ? void 0 : _props$pushNotificati.disableNotificationRegistration;
|
|
53
|
+
let snippet = '';
|
|
54
|
+
// unless this property is explicity set to true, push notification
|
|
55
|
+
// registration will be added to the AppDelegate
|
|
56
|
+
if (disableNotificationRegistration !== true) {
|
|
57
|
+
snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;
|
|
58
|
+
}
|
|
59
|
+
handlerFileContent = replaceCodeByRegex(handlerFileContent, CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER, snippet);
|
|
60
|
+
const autoTrackPushEvents = ((_props$pushNotificati2 = props.pushNotification) === null || _props$pushNotificati2 === void 0 ? void 0 : _props$pushNotificati2.autoTrackPushEvents) !== false;
|
|
61
|
+
handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
62
|
+
const autoFetchDeviceToken = ((_props$pushNotificati3 = props.pushNotification) === null || _props$pushNotificati3 === void 0 ? void 0 : _props$pushNotificati3.autoFetchDeviceToken) !== false;
|
|
63
|
+
handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
|
|
64
|
+
const showPushAppInForeground = ((_props$pushNotificati4 = props.pushNotification) === null || _props$pushNotificati4 === void 0 ? void 0 : _props$pushNotificati4.showPushAppInForeground) !== false;
|
|
65
|
+
handlerFileContent = replaceCodeByRegex(handlerFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
66
|
+
FileManagement.writeFile(handlerDestPath, handlerFileContent);
|
|
67
|
+
return config;
|
|
68
|
+
};
|
|
69
|
+
export const withCIOIosSwift = (configOuter, props) => {
|
|
70
|
+
// First, copy the CioSdkAppDelegateHandler.swift file to the iOS project and add it to Xcode project
|
|
71
|
+
configOuter = withXcodeProject(configOuter, async config => {
|
|
72
|
+
return copyAndConfigureAppDelegateHandler(config, props);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Then modify the AppDelegate
|
|
76
|
+
return withAppDelegate(configOuter, async config => {
|
|
77
|
+
return modifyAppDelegate(config, props);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Modify the AppDelegate to integrate with Customer.io SDK
|
|
83
|
+
*/
|
|
84
|
+
const modifyAppDelegate = (config, props) => {
|
|
85
|
+
var _props$pushNotificati5;
|
|
86
|
+
const appDelegateContent = config.modResults.contents;
|
|
87
|
+
|
|
88
|
+
// Check if modifications have already been applied
|
|
89
|
+
if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {
|
|
90
|
+
console.log('CustomerIO Swift AppDelegate changes already exist. Skipping...');
|
|
91
|
+
return config;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Add the handler property declaration
|
|
95
|
+
let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);
|
|
96
|
+
|
|
97
|
+
// Modify didFinishLaunchingWithOptions to initialize and call the handler
|
|
98
|
+
modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent);
|
|
99
|
+
|
|
100
|
+
// Add didRegisterForRemoteNotificationsWithDeviceToken implementation
|
|
101
|
+
modifiedContent = addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);
|
|
102
|
+
|
|
103
|
+
// Add didFailToRegisterForRemoteNotificationsWithError implementation
|
|
104
|
+
modifiedContent = addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);
|
|
105
|
+
|
|
106
|
+
// Add deep link handling for killed state if enabled
|
|
107
|
+
if (((_props$pushNotificati5 = props.pushNotification) === null || _props$pushNotificati5 === void 0 ? void 0 : _props$pushNotificati5.handleDeeplinkInKilledState) === true) {
|
|
108
|
+
modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);
|
|
109
|
+
}
|
|
110
|
+
config.modResults.contents = modifiedContent;
|
|
111
|
+
return config;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Check if a method exists in the AppDelegate content
|
|
116
|
+
* @param content The AppDelegate content
|
|
117
|
+
* @param methodSignature The method signature to check for
|
|
118
|
+
* @returns true if the method exists, false otherwise
|
|
119
|
+
*/
|
|
120
|
+
const methodExistsInAppDelegate = (content, methodSignature) => {
|
|
121
|
+
return content.includes(methodSignature);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Add handler property declaration to the AppDelegate class
|
|
126
|
+
* This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()
|
|
127
|
+
* to the AppDelegate class
|
|
128
|
+
*/
|
|
129
|
+
const addHandlerPropertyDeclaration = content => {
|
|
130
|
+
// Look for the AppDelegate class declaration
|
|
131
|
+
const classDeclarationRegex = /class\s+AppDelegate\s*:\s*.*\s*{/;
|
|
132
|
+
const match = content.match(classDeclarationRegex);
|
|
133
|
+
if (!match) {
|
|
134
|
+
console.warn('Could not find AppDelegate class declaration');
|
|
135
|
+
return content;
|
|
136
|
+
}
|
|
137
|
+
const position = match.index + match[0].length;
|
|
138
|
+
return content.substring(0, position) + `\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\n` + content.substring(position);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Modify didFinishLaunchingWithOptions to call the handler
|
|
143
|
+
* This adds the handler call before the return statement in didFinishLaunchingWithOptions
|
|
144
|
+
*/
|
|
145
|
+
const modifyDidFinishLaunchingWithOptions = content => {
|
|
146
|
+
// Find the return statement in didFinishLaunchingWithOptions
|
|
147
|
+
// Always look for launchOptions since modifiedLaunchOptions is only set later
|
|
148
|
+
const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
|
|
149
|
+
const returnStatementMatch = content.match(returnStatementRegex);
|
|
150
|
+
if (!returnStatementMatch) {
|
|
151
|
+
console.warn('Could not find return statement with super.application in didFinishLaunchingWithOptions');
|
|
152
|
+
return content;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Add handler call before the return statement
|
|
156
|
+
const insertPosition = returnStatementMatch.index;
|
|
157
|
+
const handlerCallCode = ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\n\n `;
|
|
158
|
+
return content.substring(0, insertPosition) + handlerCallCode + content.substring(insertPosition);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation
|
|
163
|
+
* If the method already exists, it adds the handler call to the existing method
|
|
164
|
+
* If the method doesn't exist, it adds a new method implementation
|
|
165
|
+
*/
|
|
166
|
+
const addDidRegisterForRemoteNotificationsWithDeviceToken = content => {
|
|
167
|
+
const methodSignature = 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';
|
|
168
|
+
|
|
169
|
+
// Check if method already exists
|
|
170
|
+
if (methodExistsInAppDelegate(content, methodSignature)) {
|
|
171
|
+
// Method exists, modify it to call our handler
|
|
172
|
+
const methodRegex = /func\s+application\s*\(\s*_\s+application\s*:\s*UIApplication\s*,\s*didRegisterForRemoteNotificationsWithDeviceToken\s+deviceToken\s*:\s*Data\s*\)\s*{[\s\S]*?}/;
|
|
173
|
+
const match = content.match(methodRegex);
|
|
174
|
+
if (match) {
|
|
175
|
+
// Add our handler call to the existing method
|
|
176
|
+
const methodContent = match[0];
|
|
177
|
+
const openBraceIndex = methodContent.indexOf('{') + 1;
|
|
178
|
+
const modifiedMethod = methodContent.substring(0, openBraceIndex) + '\n // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n' + methodContent.substring(openBraceIndex);
|
|
179
|
+
return content.replace(methodRegex, modifiedMethod);
|
|
180
|
+
}
|
|
181
|
+
return content;
|
|
182
|
+
} else {
|
|
183
|
+
// Method doesn't exist, add it inside the AppDelegate class
|
|
184
|
+
// Find the end of the AppDelegate class
|
|
185
|
+
const classEndRegex = /^}(\s*$|\s*\/\/)/m;
|
|
186
|
+
const classEndMatch = content.match(classEndRegex);
|
|
187
|
+
if (!classEndMatch) {
|
|
188
|
+
console.warn('Could not find end of AppDelegate class');
|
|
189
|
+
return content;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Insert the method inside the class
|
|
193
|
+
const position = classEndMatch.index;
|
|
194
|
+
return content.substring(0, position) + '\n // Handle device token registration\n' + ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\n' + ' // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n' + ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\n' + ' }\n' + content.substring(position);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Add or modify didFailToRegisterForRemoteNotificationsWithError implementation
|
|
200
|
+
* If the method already exists, it adds the handler call to the existing method
|
|
201
|
+
* If the method doesn't exist, it adds a new method implementation
|
|
202
|
+
*/
|
|
203
|
+
const addDidFailToRegisterForRemoteNotificationsWithError = content => {
|
|
204
|
+
const methodSignature = 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';
|
|
205
|
+
|
|
206
|
+
// Check if method already exists
|
|
207
|
+
if (methodExistsInAppDelegate(content, methodSignature)) {
|
|
208
|
+
// Method exists, modify it to call our handler
|
|
209
|
+
const methodRegex = /func\s+application\s*\(\s*_\s+application\s*:\s*UIApplication\s*,\s*didFailToRegisterForRemoteNotificationsWithError\s+error\s*:\s*Error\s*\)\s*{[\s\S]*?}/;
|
|
210
|
+
const match = content.match(methodRegex);
|
|
211
|
+
if (match) {
|
|
212
|
+
// Add our handler call to the existing method
|
|
213
|
+
const methodContent = match[0];
|
|
214
|
+
const openBraceIndex = methodContent.indexOf('{') + 1;
|
|
215
|
+
const modifiedMethod = methodContent.substring(0, openBraceIndex) + '\n // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\n' + methodContent.substring(openBraceIndex);
|
|
216
|
+
return content.replace(methodRegex, modifiedMethod);
|
|
217
|
+
}
|
|
218
|
+
return content;
|
|
219
|
+
} else {
|
|
220
|
+
// Method doesn't exist, add it inside the AppDelegate class
|
|
221
|
+
// Find the end of the AppDelegate class
|
|
222
|
+
const classEndRegex = /^}(\s*$|\s*\/\/)/m;
|
|
223
|
+
const classEndMatch = content.match(classEndRegex);
|
|
224
|
+
if (!classEndMatch) {
|
|
225
|
+
console.warn('Could not find end of AppDelegate class');
|
|
226
|
+
return content;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Insert the method inside the class
|
|
230
|
+
const position = classEndMatch.index;
|
|
231
|
+
return content.substring(0, position) + '\n // Handle remote notification registration errors\n' + ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\n' + ' // Call CustomerIO SDK handler\n' + ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\n' + ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\n' + ' }\n' + content.substring(position);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Add deep link handling for killed state
|
|
237
|
+
* This replaces the return statement with deep link handling code
|
|
238
|
+
* and a modified return statement that uses modifiedLaunchOptions
|
|
239
|
+
*/
|
|
240
|
+
const addHandleDeeplinkInKilledState = content => {
|
|
241
|
+
// Check if deep link code snippet is already present
|
|
242
|
+
const deepLinkMarker = "Deep link workaround for app killed state start";
|
|
243
|
+
if (content.includes(deepLinkMarker)) {
|
|
244
|
+
return content;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Find the return statement with launchOptions
|
|
248
|
+
const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
|
|
249
|
+
const returnStatementMatch = content.match(returnStatementRegex);
|
|
250
|
+
if (!returnStatementMatch) {
|
|
251
|
+
console.warn("Could not find return statement with launchOptions");
|
|
252
|
+
return content;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Create the replacement code with deep link handling and modified return statement
|
|
256
|
+
const modifiedReturnStatement = "return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)";
|
|
257
|
+
const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + "\n\n " + modifiedReturnStatement;
|
|
258
|
+
|
|
259
|
+
// Replace the return statement with deep link handling code and modified return statement
|
|
260
|
+
return content.replace(returnStatementRegex, replacementCode);
|
|
261
|
+
};
|
|
262
|
+
//# sourceMappingURL=withCIOIosSwift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withAppDelegate","withXcodeProject","path","FileManagement","LOCAL_PATH_TO_CIO_NSE_FILES","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","replaceCodeByRegex","isFcmPushProvider","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","props","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","projectRoot","modRequest","iosProjectRoot","join","useFcm","handlerSourcePath","projectName","console","warn","handlerDestPath","copyFile","xcodeProject","modResults","group","existingGroup","pbxGroupByName","pbxCreateGroup","classesKey","findPBXGroupKey","name","addToPbxGroup","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","pushNotification","snippet","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","writeFile","withCIOIosSwift","configOuter","modifyAppDelegate","_props$pushNotificati5","appDelegateContent","contents","includes","log","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","methodExistsInAppDelegate","content","methodSignature","classDeclarationRegex","match","position","index","length","substring","returnStatementRegex","returnStatementMatch","insertPosition","handlerCallCode","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","replace","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport {\n withAppDelegate,\n withXcodeProject,\n} from '@expo/config-plugins';\nimport path from 'path';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport {\n LOCAL_PATH_TO_CIO_NSE_FILES,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: any,\n props: CustomerIOPluginOptionsIOS\n): any => {\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n LOCAL_PATH_TO_CIO_NSE_FILES,\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n console.warn(\n 'Project name is undefined, cannot copy CioSdkAppDelegateHandler.swift'\n );\n return config;\n }\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n const xcodeProject = config.modResults;\n\n // Create a group for CustomerIO files if it doesn't exist\n let group;\n const existingGroup = xcodeProject.pbxGroupByName('CustomerIO');\n if (existingGroup) {\n group = existingGroup;\n } else {\n group = xcodeProject.pbxCreateGroup('CustomerIO');\n const classesKey = xcodeProject.findPBXGroupKey({ name: projectName });\n xcodeProject.addToPbxGroup(group, classesKey);\n }\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n\n return config;\n};\n\nexport const withCIOIosSwift: ConfigPlugin<CustomerIOPluginOptionsIOS> = (\n configOuter,\n props\n) => {\n // First, copy the CioSdkAppDelegateHandler.swift file to the iOS project and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, props);\n });\n\n // Then modify the AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegate(config, props);\n });\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegate = (\n config: any,\n props: CustomerIOPluginOptionsIOS\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n console.log(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(modifiedContent);\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n \n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n console.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = match.index! + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to call the handler\n * This adds the handler call before the return statement in didFinishLaunchingWithOptions\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex = /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n \n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n console.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Add handler call before the return statement\n const insertPosition = returnStatementMatch.index!;\n const handlerCallCode = ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `;\n \n return (\n content.substring(0, insertPosition) +\n handlerCallCode +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature = 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n \n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n console.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index!;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature = 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n \n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n console.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index!;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = \"Deep link workaround for app killed state start\";\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex = /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n \n if (!returnStatementMatch) {\n console.warn(\"Could not find return statement with launchOptions\");\n return content;\n }\n \n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement = \"return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)\";\n const replacementCode = CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + \"\\n\\n \" + modifiedReturnStatement;\n \n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":"AACA,SACEA,eAAe,EACfC,gBAAgB,QACX,sBAAsB;AAC7B,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SACEC,2BAA2B,EAC3BC,wCAAwC,EACxCC,0CAA0C,EAC1CC,+CAA+C,QAC1C,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,iBAAiB,QAAQ,SAAS;;AAE3C;AACA,MAAMC,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,C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,KAAK,CAACK,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzBlD,OAAO,CAACC,IAAI,CAAC,oDAAoD,CAAC;IAClE,OAAOwC,OAAO;EAChB;;EAEA;EACA,MAAMqB,uBAAuB,GAAG,6FAA6F;EAC7H,MAAMC,eAAe,GAAGlF,+CAA+C,GAAG,UAAU,GAAGiF,uBAAuB;;EAE9G;EACA,OAAOrB,OAAO,CAACiB,OAAO,CAACT,oBAAoB,EAAEc,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","IOSConfig","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import {\n withXcodeProject,\n IOSConfig,\n
|
|
1
|
+
{"version":3,"names":["withXcodeProject","IOSConfig","FileManagement","isFcmPushProvider","withGoogleServicesJsonFile","config","cioProps","props","_cioProps$pushNotific","useFcm","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","project","fileName","groupName","filepath","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import {\n withXcodeProject,\n IOSConfig,\n} from '@expo/config-plugins';\nimport type { ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch (e) {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: any, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":"AAAA,SACEA,gBAAgB,EAChBC,SAAS,QACJ,sBAAsB;AAG7B,SAASC,cAAc,QAAQ,mCAAmC;AAElE,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,OAAO,MAAMC,0BAEZ,GAAGA,CAACC,MAAM,EAAEC,QAAQ,KAAK;EACxB,OAAON,gBAAgB,CAACK,MAAM,EAAE,MAAOE,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAGN,iBAAiB,CAACG,QAAQ,CAAC;IAC1C,IAAI,CAACG,MAAM,EAAE;MACX;MACA,OAAOF,KAAK;IACd;IAEAG,OAAO,CAACC,GAAG,CACT,0GAA0G,GACxG,2DACJ,CAAC;;IAED;IACA,MAAMC,OAAO,GAAGL,KAAK,CAACM,UAAU,CAACC,mBAAmB;IACpD,MAAMC,kBAAkB,IAAAP,qBAAA,GAAGF,QAAQ,CAACU,gBAAgB,cAAAR,qBAAA,uBAAzBA,qBAAA,CAA2BO,kBAAkB;IACxE,MAAME,OAAO,GAAGV,KAAK,CAACM,UAAU,CAACK,WAAW;IAE5C,IAAIhB,cAAc,CAACiB,MAAM,CAAC,GAAGP,OAAO,2BAA2B,CAAC,EAAE;MAChEF,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,wCACjC,CAAC;MACD,OAAOL,KAAK;IACd;IAEA,IACEL,cAAc,CAACiB,MAAM,CAAC,GAAGP,OAAO,IAAIK,OAAO,2BAA2B,CAAC,EACvE;MACA;MACA;MACAP,OAAO,CAACC,GAAG,CACT,wBAAwBC,OAAO,IAAIK,OAAO,wCAC5C,CAAC;MACD,OAAOV,KAAK;IACd;IAEA,IAAIQ,kBAAkB,IAAIb,cAAc,CAACiB,MAAM,CAACJ,kBAAkB,CAAC,EAAE;MAAA,IAAAK,WAAA;MACnE,KAAAA,WAAA,GAAIf,MAAM,CAACgB,GAAG,cAAAD,WAAA,eAAVA,WAAA,CAAYL,kBAAkB,EAAE;QAClCL,OAAO,CAACY,IAAI,CACV,0HAA0H,GACxH,uIACJ,CAAC;MACH;MAEA,IAAI;QACFpB,cAAc,CAACqB,QAAQ,CACrBR,kBAAkB,EAClB,GAAGH,OAAO,2BACZ,CAAC;QAEDY,qBAAqB,CAACjB,KAAK,CAACkB,UAAU,EAAE,0BAA0B,CAAC;MACrE,CAAC,CAAC,OAAOC,CAAC,EAAE;QACVhB,OAAO,CAACiB,KAAK,CACX,gGAAgGf,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACiB,KAAK,CACX,wCAAwCZ,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAOL,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAED,SAASiB,qBAAqBA,CAACI,OAAY,EAAEC,QAAgB,EAAE;EAC7D,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAAC5B,SAAS,CAAC+B,UAAU,CAACC,sBAAsB,CAACL,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEpB,OAAO,CAACiB,KAAK,CACX,qEAAqEG,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACA7B,SAAS,CAAC+B,UAAU,CAACE,sBAAsB,CAAC;IAC1CN,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTK,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -3,14 +3,15 @@ import { CIO_NOTIFICATION_TARGET_NAME, CIO_REGISTER_PUSHNOTIFICATION_SNIPPET, DE
|
|
|
3
3
|
import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
4
4
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
5
5
|
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
6
|
-
import { isFcmPushProvider } from './utils';
|
|
6
|
+
import { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';
|
|
7
7
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
8
8
|
const ENV_FILENAME = 'Env.swift';
|
|
9
9
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
10
|
-
const addNotificationServiceExtension = async (options, xcodeProject) => {
|
|
10
|
+
const addNotificationServiceExtension = async (options, xcodeProject, isExpoVersion53OrHigher) => {
|
|
11
11
|
try {
|
|
12
12
|
var _options$pushNotifica;
|
|
13
|
-
|
|
13
|
+
// PushService file is only needed for pre-Expo 53 code generation
|
|
14
|
+
if (options.pushNotification && !isExpoVersion53OrHigher) {
|
|
14
15
|
await addPushNotificationFile(options, xcodeProject);
|
|
15
16
|
}
|
|
16
17
|
if (((_options$pushNotifica = options.pushNotification) === null || _options$pushNotifica === void 0 ? void 0 : _options$pushNotifica.useRichPush) === true) {
|
|
@@ -65,7 +66,7 @@ export const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
65
66
|
useFrameworks,
|
|
66
67
|
iosDeploymentTarget
|
|
67
68
|
};
|
|
68
|
-
const modifiedProjectFile = await addNotificationServiceExtension(options, config.modResults);
|
|
69
|
+
const modifiedProjectFile = await addNotificationServiceExtension(options, config.modResults, isExpoVersion53OrHigher(configOuter));
|
|
69
70
|
if (modifiedProjectFile) {
|
|
70
71
|
config.modResults = modifiedProjectFile;
|
|
71
72
|
}
|
|
@@ -1 +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","isFcmPushProvider","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","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","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","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","env","regionMap","us","eu","mappedRegion","toLowerCase","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","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';\nimport { isFcmPushProvider } from './utils';\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 === true) {\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 { appleTeamId, iosDeploymentTarget, useFrameworks } = 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 } satisfies CustomerIOPluginOptionsIOS;\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 const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\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 platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${\n isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${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 [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common 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 const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey\n );\n\n if (region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const mappedRegion = (regionMap as any)[region.toLowerCase()] || '';\n if (!mappedRegion) {\n console.warn(\n `${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 // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\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(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} 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}/${targetFileName}`, 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 const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PU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,KAAK;EACzD7B,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,gCAAgC,EAChC6B,mBAAmB,CAACC,QAAQ,CAAC,CAC/B,CAAC;EAED,MAAMC,oBAAoB,GACxB,EAAAR,sBAAA,GAAA3G,OAAO,CAACG,gBAAgB,cAAAwG,sBAAA,uBAAxBA,sBAAA,CAA0BQ,oBAAoB,MAAK,KAAK;EAC1D/B,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,iCAAiC,EACjC+B,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAR,sBAAA,GAAA5G,OAAO,CAACG,gBAAgB,cAAAyG,sBAAA,uBAAxBA,sBAAA,CAA0BQ,uBAAuB,MAAK,KAAK;EAC7DhC,cAAc,GAAG5F,kBAAkB,CACjC4F,cAAc,EACd,qCAAqC,EACrCgC,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAEDxH,cAAc,CAACqF,SAAS,CAACC,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
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","isExpoVersion53OrHigher","isFcmPushProvider","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","isFcmProvider","pbxTargetByName","warn","nsePath","mkdir","recursive","platformSpecificFiles","commonFiles","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","CDP_API_KEY_RE","REGION_RE","envFileContent","cdpApiKey","region","env","regionMap","us","eu","mappedRegion","toLowerCase","sourceFile","targetFileName","appPath","exists","log","updatePushFile","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile","_options$pushNotifica3","_options$pushNotifica4","_options$pushNotifica5","_options$pushNotifica6","_options$pushNotifica7","REGISTER_RE","disableNotificationRegistration","snippet","toUpperCase","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin, XcodeProject } from '@expo/config-plugins';\nimport { withXcodeProject } 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';\nimport { isExpoVersion53OrHigher, isFcmPushProvider } from './utils';\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 isExpoVersion53OrHigher: boolean\n) => {\n try {\n // PushService file is only needed for pre-Expo 53 code generation\n if (options.pushNotification && !isExpoVersion53OrHigher) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush === true) {\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 { appleTeamId, iosDeploymentTarget, useFrameworks } = 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 } satisfies CustomerIOPluginOptionsIOS;\n\n const modifiedProjectFile = await addNotificationServiceExtension(\n options,\n config.modResults,\n isExpoVersion53OrHigher(configOuter)\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 const isFcmProvider = isFcmPushProvider(options);\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);\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 platformSpecificFiles = ['NotificationService.swift'];\n\n const commonFiles = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n // Copy platform-specific files\n platformSpecificFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${\n isFcmProvider ? 'fcm' : 'apn'\n }/${filename}`,\n targetFile\n );\n });\n\n // Copy common files\n commonFiles.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${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 [...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common 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 const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n envFileContent = replaceCodeByRegex(\n envFileContent,\n CDP_API_KEY_RE,\n cdpApiKey\n );\n\n if (region) {\n const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const mappedRegion = (regionMap as any)[region.toLowerCase()] || '';\n if (!mappedRegion) {\n console.warn(\n `${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 // Maybe copy a different file with FCM config based on config\n const { iosPath, appName } = options;\n const isFcmProvider = isFcmPushProvider(options);\n // PushService.swift is platform-specific and always lives in the platform folder\n const sourceFile = `${isFcmProvider ? 'fcm' : 'apn'}/PushService.swift`;\n const targetFileName = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n const targetFile = getTargetFile(targetFileName);\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(targetFileName))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(targetFileName)} 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}/${targetFileName}`, 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 const disableNotificationRegistration =\n options.pushNotification?.disableNotificationRegistration;\n const { cdpApiKey, region } = options.pushNotification?.env || {\n cdpApiKey: undefined,\n region: undefined,\n };\n if (!cdpApiKey) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.pushNotification.env.cdpApiKey is missing from app.config.js or app.json.'\n );\n }\n\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET;\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGISTER_RE, snippet);\n\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{CDP_API_KEY\\}\\}/,\n cdpApiKey\n );\n\n if (region) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{REGION\\}\\}/,\n region.toUpperCase()\n );\n }\n\n const autoTrackPushEvents =\n options.pushNotification?.autoTrackPushEvents !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n options.pushNotification?.autoFetchDeviceToken !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n options.pushNotification?.showPushAppInForeground !== false;\n envFileContent = replaceCodeByRegex(\n envFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SACEC,4BAA4B,EAC5BC,qCAAqC,EACrCC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,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GACxB,EAAAR,sBAAA,GAAA3G,OAAO,CAACG,gBAAgB,cAAAwG,sBAAA,uBAAxBA,sBAAA,CAA0BQ,oBAAoB,MAAK,KAAK;EAC1D/B,cAAc,GAAG7F,kBAAkB,CACjC6F,cAAc,EACd,iCAAiC,EACjC+B,oBAAoB,CAACD,QAAQ,CAAC,CAChC,CAAC;EAED,MAAME,uBAAuB,GAC3B,EAAAR,sBAAA,GAAA5G,OAAO,CAACG,gBAAgB,cAAAyG,sBAAA,uBAAxBA,sBAAA,CAA0BQ,uBAAuB,MAAK,KAAK;EAC7DhC,cAAc,GAAG7F,kBAAkB,CACjC6F,cAAc,EACd,qCAAqC,EACrCgC,uBAAuB,CAACF,QAAQ,CAAC,CACnC,CAAC;EAEDzH,cAAc,CAACsF,SAAS,CAACC,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withXcodeProject","isFcmPushProvider","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","iosPath","modRequest","platformProjectRoot"],"sources":["withXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin
|
|
1
|
+
{"version":3,"names":["withXcodeProject","isFcmPushProvider","injectCIOPodfileCode","withCioXcodeProject","config","cioProps","props","iosPath","modRequest","platformProjectRoot"],"sources":["withXcodeProject.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withXcodeProject } from '@expo/config-plugins';\n\nimport { isFcmPushProvider } from './utils';\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 iosPath = props.modRequest.platformProjectRoot;\n\n await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));\n\n return props;\n });\n};\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,sBAAsB;AAEvD,SAASC,iBAAiB,QAAQ,SAAS;AAC3C,SAASC,oBAAoB,QAAQ,uCAAuC;AAG5E,OAAO,MAAMC,mBAA6D,GAAGA,CAC3EC,MAAM,EACNC,QAAQ,KACL;EACH,OAAOL,gBAAgB,CAACI,MAAM,EAAE,MAAOE,KAAK,IAAK;IAC/C,MAAMC,OAAO,GAAGD,KAAK,CAACE,UAAU,CAACC,mBAAmB;IAEpD,MAAMP,oBAAoB,CAACK,OAAO,EAAEN,iBAAiB,CAACI,QAAQ,CAAC,CAAC;IAEhE,OAAOC,KAAK;EACd,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
3
3
|
export declare const withAndroidManifestUpdates: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsAndroid } from '../types/cio-types';
|
|
3
3
|
export declare const withAppGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
3
3
|
export declare const withGistMavenRepository: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
3
3
|
export declare const withGoogleServicesJSON: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';
|
|
3
3
|
export declare const withProjectGoogleServices: ConfigPlugin<CustomerIOPluginOptionsAndroid>;
|
|
@@ -27,4 +27,7 @@ export declare const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPE
|
|
|
27
27
|
export declare const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = "\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n";
|
|
28
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
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_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = "\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n";
|
|
30
31
|
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 }";
|
|
32
|
+
export declare const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = "\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 }";
|
|
33
|
+
export declare const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER: RegExp;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { MakeDirectoryOptions } from 'fs';
|
|
1
|
+
import type { MakeDirectoryOptions } from 'fs';
|
|
3
2
|
export declare class FileManagement {
|
|
4
3
|
static read(path: string): Promise<string>;
|
|
5
4
|
static write(path: string, contents: string): Promise<void>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
2
|
+
import type { ExpoConfig } from '@expo/config-types';
|
|
2
3
|
/**
|
|
3
4
|
* Returns t
|
|
4
5
|
* @param iosOptions The plugin iOS configuration options
|
|
5
6
|
* @returns true if FCM is configured to be used as push provider
|
|
6
7
|
*/
|
|
7
8
|
export declare const isFcmPushProvider: (iosOptions?: CustomerIOPluginOptionsIOS) => boolean;
|
|
9
|
+
export declare const isExpoVersion53OrHigher: (config: ExpoConfig) => boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
3
3
|
export declare const withAppDelegateModifications: ConfigPlugin<CustomerIOPluginOptionsIOS>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ConfigPlugin } from '@expo/config-plugins';
|
|
1
|
+
import type { ConfigPlugin } from '@expo/config-plugins';
|
|
2
2
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
3
3
|
export declare const withGoogleServicesJsonFile: ConfigPlugin<CustomerIOPluginOptionsIOS>;
|