customerio-expo-plugin 2.0.0-beta.1 → 2.0.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 +11 -5
- package/plugin/{src/helpers/native-files/ios → lib/commonjs/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +17 -0
- package/plugin/lib/commonjs/ios/utils.js.map +1 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +2 -0
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +68 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +2 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/{commonjs/helpers/native-files/ios → module/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +10 -0
- package/plugin/lib/module/ios/utils.js.map +1 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +2 -0
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +61 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +2 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -2
- package/plugin/lib/typescript/ios/utils.d.ts +7 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +3 -0
- package/plugin/lib/typescript/types/cio-types.d.ts +3 -0
- package/plugin/{lib/module/helpers/native-files/ios → src/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +5 -4
- package/plugin/src/ios/utils.ts +10 -0
- package/plugin/src/ios/withAppDelegateModifications.ts +15 -0
- package/plugin/src/ios/withCIOIos.ts +2 -0
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +97 -0
- package/plugin/src/ios/withNotificationsXcodeProject.ts +40 -12
- package/plugin/src/ios/withXcodeProject.ts +2 -1
- package/plugin/src/types/cio-types.ts +3 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
|
@@ -14,6 +14,7 @@ import { replaceCodeByRegex } from '../helpers/utils/codeInjection';
|
|
|
14
14
|
import { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
15
15
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
16
16
|
import { FileManagement } from './../helpers/utils/fileManagement';
|
|
17
|
+
import { isFcmPushProvider } from './utils';
|
|
17
18
|
|
|
18
19
|
const PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
19
20
|
const ENV_FILENAME = 'Env.swift';
|
|
@@ -118,7 +119,9 @@ const addRichPushXcodeProj = async (
|
|
|
118
119
|
useFrameworks,
|
|
119
120
|
} = options;
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
const isFcmProvider = isFcmPushProvider(options);
|
|
123
|
+
|
|
124
|
+
await injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmProvider);
|
|
122
125
|
|
|
123
126
|
// Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
|
|
124
127
|
// If true then skip creating a new group to avoid duplicate folders
|
|
@@ -134,20 +137,32 @@ const addRichPushXcodeProj = async (
|
|
|
134
137
|
recursive: true,
|
|
135
138
|
});
|
|
136
139
|
|
|
137
|
-
const
|
|
140
|
+
const platformSpecificFiles = [
|
|
141
|
+
'NotificationService.swift',
|
|
142
|
+
];
|
|
143
|
+
|
|
144
|
+
const commonFiles = [
|
|
138
145
|
PLIST_FILENAME,
|
|
139
146
|
'NotificationService.h',
|
|
140
|
-
'NotificationService.swift',
|
|
141
147
|
'NotificationService.m',
|
|
142
148
|
ENV_FILENAME,
|
|
143
149
|
];
|
|
144
150
|
|
|
145
151
|
const getTargetFile = (filename: string) => `${nsePath}/${filename}`;
|
|
152
|
+
// Copy platform-specific files
|
|
153
|
+
platformSpecificFiles.forEach((filename) => {
|
|
154
|
+
const targetFile = getTargetFile(filename);
|
|
155
|
+
FileManagement.copyFile(
|
|
156
|
+
`${LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? "fcm" : "apn"}/${filename}`,
|
|
157
|
+
targetFile
|
|
158
|
+
);
|
|
159
|
+
});
|
|
146
160
|
|
|
147
|
-
|
|
161
|
+
// Copy common files
|
|
162
|
+
commonFiles.forEach((filename) => {
|
|
148
163
|
const targetFile = getTargetFile(filename);
|
|
149
164
|
FileManagement.copyFile(
|
|
150
|
-
`${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,
|
|
165
|
+
`${LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`,
|
|
151
166
|
targetFile
|
|
152
167
|
);
|
|
153
168
|
});
|
|
@@ -163,7 +178,7 @@ const addRichPushXcodeProj = async (
|
|
|
163
178
|
|
|
164
179
|
// Create new PBXGroup for the extension
|
|
165
180
|
const extGroup = xcodeProject.addPbxGroup(
|
|
166
|
-
files,
|
|
181
|
+
[...platformSpecificFiles, ...commonFiles], // Combine platform-specific and common files,
|
|
167
182
|
CIO_NOTIFICATION_TARGET_NAME,
|
|
168
183
|
CIO_NOTIFICATION_TARGET_NAME
|
|
169
184
|
);
|
|
@@ -319,25 +334,29 @@ async function addPushNotificationFile(
|
|
|
319
334
|
options: CustomerIOPluginOptionsIOS,
|
|
320
335
|
xcodeProject: any
|
|
321
336
|
) {
|
|
337
|
+
// Maybe copy a different file with FCM config based on config
|
|
322
338
|
const { iosPath, appName } = options;
|
|
323
|
-
const
|
|
339
|
+
const isFcmProvider = isFcmPushProvider(options);
|
|
340
|
+
// PushService.swift is platform-specific and always lives in the platform folder
|
|
341
|
+
const sourceFile = `${isFcmProvider ? "fcm" : "apn"}/PushService.swift`;
|
|
342
|
+
const targetFileName = 'PushService.swift';
|
|
324
343
|
const appPath = `${iosPath}/${appName}`;
|
|
325
344
|
const getTargetFile = (filename: string) => `${appPath}/${filename}`;
|
|
326
|
-
const targetFile = getTargetFile(
|
|
345
|
+
const targetFile = getTargetFile(targetFileName);
|
|
327
346
|
|
|
328
347
|
// Check whether {file} exists in the project. If false, then add the file
|
|
329
348
|
// If {file} exists then skip and return
|
|
330
|
-
if (!FileManagement.exists(getTargetFile(
|
|
349
|
+
if (!FileManagement.exists(getTargetFile(targetFileName))) {
|
|
331
350
|
FileManagement.mkdir(appPath, {
|
|
332
351
|
recursive: true,
|
|
333
352
|
});
|
|
334
353
|
|
|
335
354
|
FileManagement.copyFile(
|
|
336
|
-
`${LOCAL_PATH_TO_CIO_NSE_FILES}/${
|
|
355
|
+
`${LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`,
|
|
337
356
|
targetFile
|
|
338
357
|
);
|
|
339
358
|
} else {
|
|
340
|
-
console.log(`${getTargetFile(
|
|
359
|
+
console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
|
|
341
360
|
return;
|
|
342
361
|
}
|
|
343
362
|
|
|
@@ -347,7 +366,7 @@ async function addPushNotificationFile(
|
|
|
347
366
|
const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });
|
|
348
367
|
xcodeProject.addToPbxGroup(group, classesKey);
|
|
349
368
|
|
|
350
|
-
xcodeProject.addSourceFile(`${appName}/${
|
|
369
|
+
xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
|
|
351
370
|
}
|
|
352
371
|
|
|
353
372
|
const updatePushFile = (
|
|
@@ -389,6 +408,15 @@ const updatePushFile = (
|
|
|
389
408
|
autoTrackPushEvents.toString()
|
|
390
409
|
);
|
|
391
410
|
|
|
411
|
+
const autoFetchDeviceToken =
|
|
412
|
+
options.autoFetchDeviceToken === undefined ||
|
|
413
|
+
options.autoFetchDeviceToken === true;
|
|
414
|
+
envFileContent = replaceCodeByRegex(
|
|
415
|
+
envFileContent,
|
|
416
|
+
/\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/,
|
|
417
|
+
autoFetchDeviceToken.toString()
|
|
418
|
+
);
|
|
419
|
+
|
|
392
420
|
const showPushAppInForeground =
|
|
393
421
|
options.showPushAppInForeground === undefined ||
|
|
394
422
|
options.showPushAppInForeground === true;
|
|
@@ -2,6 +2,7 @@ import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';
|
|
|
2
2
|
|
|
3
3
|
import { injectCIOPodfileCode } from '../helpers/utils/injectCIOPodfileCode';
|
|
4
4
|
import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';
|
|
5
|
+
import { isFcmPushProvider } from './utils';
|
|
5
6
|
|
|
6
7
|
export const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (
|
|
7
8
|
config,
|
|
@@ -18,7 +19,7 @@ export const withCioXcodeProject: ConfigPlugin<CustomerIOPluginOptionsIOS> = (
|
|
|
18
19
|
};
|
|
19
20
|
const { iosPath } = options;
|
|
20
21
|
|
|
21
|
-
await injectCIOPodfileCode(iosPath);
|
|
22
|
+
await injectCIOPodfileCode(iosPath, isFcmPushProvider(cioProps));
|
|
22
23
|
|
|
23
24
|
return props;
|
|
24
25
|
});
|
|
@@ -22,9 +22,12 @@ export type CustomerIOPluginOptionsIOS = {
|
|
|
22
22
|
handleNotificationClick?: boolean;
|
|
23
23
|
showPushAppInForeground?: boolean;
|
|
24
24
|
autoTrackPushEvents?: boolean;
|
|
25
|
+
autoFetchDeviceToken?: boolean;
|
|
25
26
|
handleDeeplinkInKilledState?: boolean;
|
|
26
27
|
useFrameworks?: 'static' | 'dynamic';
|
|
27
28
|
pushNotification?: {
|
|
29
|
+
provider?: 'apn' | 'fcm';
|
|
30
|
+
googleServicesFile?: string;
|
|
28
31
|
useRichPush: boolean;
|
|
29
32
|
env: {
|
|
30
33
|
cdpApiKey: string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/plugin/src/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h}
RENAMED
|
File without changes
|
/package/plugin/src/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m}
RENAMED
|
File without changes
|