customerio-expo-plugin 1.0.0-alpha.5 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/lib/commonjs/android/withGoogleServicesJSON.js +7 -5
- package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/commonjs/helpers/constants/ios.js +5 -52
- package/lib/commonjs/helpers/constants/ios.js.map +1 -1
- package/lib/commonjs/helpers/native-files/ios/Env.swift +8 -0
- package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +4 -1
- package/lib/commonjs/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +1 -3
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/commonjs/index.js +0 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ios/withCIOIos.js +2 -7
- package/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js +145 -74
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/commonjs/postInstall.js +7 -0
- package/lib/commonjs/postInstall.js.map +1 -0
- package/lib/commonjs/postInstallHelper.js +20 -0
- package/lib/commonjs/postInstallHelper.js.map +1 -0
- package/lib/commonjs/types/cio-types.js.map +1 -1
- package/lib/module/android/withGoogleServicesJSON.js +7 -5
- package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
- package/lib/module/helpers/constants/ios.js +3 -47
- package/lib/module/helpers/constants/ios.js.map +1 -1
- package/lib/module/helpers/native-files/ios/Env.swift +8 -0
- package/lib/module/helpers/native-files/ios/NotificationService.swift +4 -1
- package/lib/module/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +2 -4
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/ios/withCIOIos.js +2 -7
- package/lib/module/ios/withCIOIos.js.map +1 -1
- package/lib/module/ios/withNotificationsXcodeProject.js +145 -74
- package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/lib/module/postInstall.js +5 -0
- package/lib/module/postInstall.js.map +1 -0
- package/lib/module/postInstallHelper.js +18 -0
- package/lib/module/postInstallHelper.js.map +1 -0
- package/lib/module/types/cio-types.js.map +1 -1
- package/lib/typescript/helpers/constants/ios.d.ts +2 -5
- package/lib/typescript/types/cio-types.d.ts +6 -1
- package/package.json +9 -5
- package/src/android/withGoogleServicesJSON.ts +9 -5
- package/src/helpers/constants/ios.ts +3 -46
- package/src/helpers/native-files/ios/Env.swift +8 -0
- package/src/helpers/native-files/ios/NotificationService.swift +4 -1
- package/src/helpers/native-files/ios/{PushNotification.swift → PushService.swift} +0 -0
- package/src/helpers/utils/injectCIOPodfileCode.ts +2 -10
- package/src/index.ts +0 -3
- package/src/ios/withCIOIos.ts +2 -8
- package/src/ios/withNotificationsXcodeProject.ts +218 -124
- package/src/postInstall.js +5 -0
- package/src/postInstallHelper.js +22 -0
- package/src/types/cio-types.ts +6 -1
- package/lib/commonjs/analytics/injectAnalytics.js +0 -31
- package/lib/commonjs/analytics/injectAnalytics.js.map +0 -1
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js +0 -79
- package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +0 -1
- package/lib/commonjs/version.js +0 -9
- package/lib/commonjs/version.js.map +0 -1
- package/lib/module/analytics/injectAnalytics.js +0 -24
- package/lib/module/analytics/injectAnalytics.js.map +0 -1
- package/lib/module/ios/withAppDelegateXcodeProject.js +0 -71
- package/lib/module/ios/withAppDelegateXcodeProject.js.map +0 -1
- package/lib/module/version.js +0 -2
- package/lib/module/version.js.map +0 -1
- package/lib/typescript/analytics/injectAnalytics.d.ts +0 -3
- package/lib/typescript/ios/withAppDelegateXcodeProject.d.ts +0 -3
- package/lib/typescript/version.d.ts +0 -1
- package/src/analytics/injectAnalytics.ts +0 -36
- package/src/ios/withAppDelegateXcodeProject.ts +0 -89
- package/src/version.ts +0 -1
|
@@ -12,92 +12,28 @@ var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
|
|
|
12
12
|
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
14
|
const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
15
|
+
const ENV_FILENAME = 'Env.swift';
|
|
15
16
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
16
17
|
const addNotificationServiceExtension = async options => {
|
|
18
|
+
// iosPath and appName are predefined from Expo config.
|
|
19
|
+
// See function withCioNotificationsXcodeProject to get where the variabes are pulled from.
|
|
17
20
|
const {
|
|
18
|
-
appleTeamId,
|
|
19
|
-
bundleIdentifier,
|
|
20
|
-
bundleShortVersion,
|
|
21
|
-
bundleVersion,
|
|
22
21
|
iosPath,
|
|
23
|
-
|
|
24
|
-
appName,
|
|
25
|
-
iosDeploymentTarget
|
|
22
|
+
appName
|
|
26
23
|
} = options;
|
|
27
24
|
const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
|
|
28
25
|
const xcodeProject = _xcode.default.project(projPath);
|
|
29
26
|
xcodeProject.parse(async function (err) {
|
|
27
|
+
var _options$pushNotifica;
|
|
30
28
|
if (err) {
|
|
31
29
|
throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
recursive: true
|
|
36
|
-
});
|
|
37
|
-
const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m'];
|
|
38
|
-
const getTargetFile = filename => `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}/${filename}`;
|
|
39
|
-
files.forEach(filename => {
|
|
40
|
-
const targetFile = getTargetFile(filename);
|
|
41
|
-
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
/* MODIFY COPIED EXTENSION FILES */
|
|
45
|
-
const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
|
|
46
|
-
updateNseInfoPlist({
|
|
47
|
-
bundleVersion,
|
|
48
|
-
bundleShortVersion,
|
|
49
|
-
infoPlistTargetFile
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// Create new PBXGroup for the extension
|
|
53
|
-
const extGroup = xcodeProject.addPbxGroup(files, _ios.CIO_NOTIFICATION_TARGET_NAME, _ios.CIO_NOTIFICATION_TARGET_NAME);
|
|
54
|
-
|
|
55
|
-
// Add the new PBXGroup to the top level group. This makes the
|
|
56
|
-
// files / folder appear in the file explorer in Xcode.
|
|
57
|
-
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
58
|
-
Object.keys(groups).forEach(key => {
|
|
59
|
-
if (groups[key].name === undefined) {
|
|
60
|
-
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// WORK AROUND for codeProject.addTarget BUG
|
|
65
|
-
// Xcode projects don't contain these if there is only one target
|
|
66
|
-
// An upstream fix should be made to the code referenced in this link:
|
|
67
|
-
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
68
|
-
const projObjects = xcodeProject.hash.project.objects;
|
|
69
|
-
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
|
|
70
|
-
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
71
|
-
if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
|
|
72
|
-
console.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
73
|
-
return;
|
|
31
|
+
if (options.pushNotification) {
|
|
32
|
+
await addPushNotificationFile(options, xcodeProject);
|
|
74
33
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// This also adds PBXTargetDependency and PBXContainerItemProxy
|
|
78
|
-
const nseTarget = xcodeProject.addTarget(_ios.CIO_NOTIFICATION_TARGET_NAME, 'app_extension', _ios.CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
|
|
79
|
-
|
|
80
|
-
// Add build phases to the new target
|
|
81
|
-
xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
82
|
-
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
83
|
-
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
84
|
-
|
|
85
|
-
// Edit the Deployment info of the target
|
|
86
|
-
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
87
|
-
for (const key in configurations) {
|
|
88
|
-
if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${_ios.CIO_NOTIFICATION_TARGET_NAME}"`) {
|
|
89
|
-
const buildSettingsObj = configurations[key].buildSettings;
|
|
90
|
-
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
91
|
-
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
|
|
92
|
-
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
93
|
-
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
94
|
-
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
95
|
-
}
|
|
34
|
+
if ((_options$pushNotifica = options.pushNotification) !== null && _options$pushNotifica !== void 0 && _options$pushNotifica.useRichPush) {
|
|
35
|
+
await addRichPushXcodeProj(options, xcodeProject);
|
|
96
36
|
}
|
|
97
|
-
|
|
98
|
-
// Add development team to the target & the main
|
|
99
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
|
|
100
|
-
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
|
|
101
37
|
_fileManagement.FileManagement.writeFile(projPath, xcodeProject.writeSync());
|
|
102
38
|
});
|
|
103
39
|
};
|
|
@@ -111,9 +47,12 @@ const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
111
47
|
const {
|
|
112
48
|
appleTeamId,
|
|
113
49
|
iosDeploymentTarget,
|
|
50
|
+
pushNotification,
|
|
114
51
|
useFrameworks
|
|
115
52
|
} = props;
|
|
116
53
|
if (ios === undefined) throw new Error('Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.');
|
|
54
|
+
|
|
55
|
+
// projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()
|
|
117
56
|
const {
|
|
118
57
|
projectName,
|
|
119
58
|
platformProjectRoot
|
|
@@ -139,13 +78,95 @@ const withCioNotificationsXcodeProject = (configOuter, props) => {
|
|
|
139
78
|
iosPath: platformProjectRoot,
|
|
140
79
|
appName: projectName,
|
|
141
80
|
useFrameworks,
|
|
142
|
-
iosDeploymentTarget
|
|
81
|
+
iosDeploymentTarget,
|
|
82
|
+
pushNotification
|
|
143
83
|
};
|
|
144
84
|
await addNotificationServiceExtension(options);
|
|
145
85
|
return config;
|
|
146
86
|
});
|
|
147
87
|
};
|
|
148
88
|
exports.withCioNotificationsXcodeProject = withCioNotificationsXcodeProject;
|
|
89
|
+
const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
90
|
+
const {
|
|
91
|
+
appleTeamId,
|
|
92
|
+
bundleIdentifier,
|
|
93
|
+
bundleShortVersion,
|
|
94
|
+
bundleVersion,
|
|
95
|
+
iosPath,
|
|
96
|
+
iosDeploymentTarget,
|
|
97
|
+
useFrameworks
|
|
98
|
+
} = options;
|
|
99
|
+
await (0, _injectCIOPodfileCode.injectCIONotificationPodfileCode)(iosPath, useFrameworks);
|
|
100
|
+
const nsePath = `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`;
|
|
101
|
+
_fileManagement.FileManagement.mkdir(nsePath, {
|
|
102
|
+
recursive: true
|
|
103
|
+
});
|
|
104
|
+
const files = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.swift', 'NotificationService.m', ENV_FILENAME];
|
|
105
|
+
const getTargetFile = filename => `${nsePath}/${filename}`;
|
|
106
|
+
files.forEach(filename => {
|
|
107
|
+
const targetFile = getTargetFile(filename);
|
|
108
|
+
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/* MODIFY COPIED EXTENSION FILES */
|
|
112
|
+
const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);
|
|
113
|
+
updateNseInfoPlist({
|
|
114
|
+
bundleVersion,
|
|
115
|
+
bundleShortVersion,
|
|
116
|
+
infoPlistTargetFile
|
|
117
|
+
});
|
|
118
|
+
updateNseEnv(options, getTargetFile(ENV_FILENAME));
|
|
119
|
+
|
|
120
|
+
// Create new PBXGroup for the extension
|
|
121
|
+
const extGroup = xcodeProject.addPbxGroup(files, _ios.CIO_NOTIFICATION_TARGET_NAME, _ios.CIO_NOTIFICATION_TARGET_NAME);
|
|
122
|
+
|
|
123
|
+
// Add the new PBXGroup to the top level group. This makes the
|
|
124
|
+
// files / folder appear in the file explorer in Xcode.
|
|
125
|
+
const groups = xcodeProject.hash.project.objects['PBXGroup'];
|
|
126
|
+
Object.keys(groups).forEach(key => {
|
|
127
|
+
if (groups[key].name === undefined) {
|
|
128
|
+
xcodeProject.addToPbxGroup(extGroup.uuid, key);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// WORK AROUND for codeProject.addTarget BUG
|
|
133
|
+
// Xcode projects don't contain these if there is only one target
|
|
134
|
+
// An upstream fix should be made to the code referenced in this link:
|
|
135
|
+
// - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
|
|
136
|
+
const projObjects = xcodeProject.hash.project.objects;
|
|
137
|
+
projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
|
|
138
|
+
projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
|
|
139
|
+
if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
|
|
140
|
+
console.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Add the NSE target
|
|
145
|
+
// This also adds PBXTargetDependency and PBXContainerItemProxy
|
|
146
|
+
const nseTarget = xcodeProject.addTarget(_ios.CIO_NOTIFICATION_TARGET_NAME, 'app_extension', _ios.CIO_NOTIFICATION_TARGET_NAME, `${bundleIdentifier}.richpush`);
|
|
147
|
+
|
|
148
|
+
// Add build phases to the new target
|
|
149
|
+
xcodeProject.addBuildPhase(['NotificationService.m', 'NotificationService.swift', 'Env.swift'], 'PBXSourcesBuildPhase', 'Sources', nseTarget.uuid);
|
|
150
|
+
xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', nseTarget.uuid);
|
|
151
|
+
xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', nseTarget.uuid);
|
|
152
|
+
|
|
153
|
+
// Edit the Deployment info of the target
|
|
154
|
+
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
|
|
155
|
+
for (const key in configurations) {
|
|
156
|
+
if (typeof configurations[key].buildSettings !== 'undefined' && configurations[key].buildSettings.PRODUCT_NAME === `"${_ios.CIO_NOTIFICATION_TARGET_NAME}"`) {
|
|
157
|
+
const buildSettingsObj = configurations[key].buildSettings;
|
|
158
|
+
buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;
|
|
159
|
+
buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET = iosDeploymentTarget || '13.0';
|
|
160
|
+
buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
|
|
161
|
+
buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
|
|
162
|
+
buildSettingsObj.SWIFT_VERSION = 4.2;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Add development team to the target & the main
|
|
167
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId, nseTarget);
|
|
168
|
+
xcodeProject.addTargetAttribute('DevelopmentTeam', appleTeamId);
|
|
169
|
+
};
|
|
149
170
|
const updateNseInfoPlist = payload => {
|
|
150
171
|
const BUNDLE_SHORT_VERSION_RE = /\{\{BUNDLE_SHORT_VERSION\}\}/;
|
|
151
172
|
const BUNDLE_VERSION_RE = /\{\{BUNDLE_VERSION\}\}/;
|
|
@@ -158,4 +179,54 @@ const updateNseInfoPlist = payload => {
|
|
|
158
179
|
}
|
|
159
180
|
_fileManagement.FileManagement.writeFile(payload.infoPlistTargetFile, plistFileString);
|
|
160
181
|
};
|
|
182
|
+
const updateNseEnv = (options, envFileName) => {
|
|
183
|
+
var _options$pushNotifica2, _options$pushNotifica3, _options$pushNotifica6, _options$pushNotifica7, _options$pushNotifica10, _options$pushNotifica11;
|
|
184
|
+
const SITE_ID_RE = /\{\{SITE_ID\}\}/;
|
|
185
|
+
const API_KEY_RE = /\{\{API_KEY\}\}/;
|
|
186
|
+
const REGION_RE = /\{\{REGION\}\}/;
|
|
187
|
+
let envFileContent = _fileManagement.FileManagement.readFile(envFileName);
|
|
188
|
+
if ((_options$pushNotifica2 = options.pushNotification) !== null && _options$pushNotifica2 !== void 0 && (_options$pushNotifica3 = _options$pushNotifica2.env) !== null && _options$pushNotifica3 !== void 0 && _options$pushNotifica3.siteId) {
|
|
189
|
+
var _options$pushNotifica4, _options$pushNotifica5;
|
|
190
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, SITE_ID_RE, (_options$pushNotifica4 = options.pushNotification) === null || _options$pushNotifica4 === void 0 ? void 0 : (_options$pushNotifica5 = _options$pushNotifica4.env) === null || _options$pushNotifica5 === void 0 ? void 0 : _options$pushNotifica5.siteId);
|
|
191
|
+
}
|
|
192
|
+
if ((_options$pushNotifica6 = options.pushNotification) !== null && _options$pushNotifica6 !== void 0 && (_options$pushNotifica7 = _options$pushNotifica6.env) !== null && _options$pushNotifica7 !== void 0 && _options$pushNotifica7.apiKey) {
|
|
193
|
+
var _options$pushNotifica8, _options$pushNotifica9;
|
|
194
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
|
|
195
|
+
}
|
|
196
|
+
if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
|
|
197
|
+
var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14, _options$pushNotifica15;
|
|
198
|
+
let region = '';
|
|
199
|
+
if (((_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : _options$pushNotifica13.region) === 'us') {
|
|
200
|
+
region = 'Region.US';
|
|
201
|
+
} else if (((_options$pushNotifica14 = options.pushNotification) === null || _options$pushNotifica14 === void 0 ? void 0 : (_options$pushNotifica15 = _options$pushNotifica14.env) === null || _options$pushNotifica15 === void 0 ? void 0 : _options$pushNotifica15.region) === 'eu') {
|
|
202
|
+
region = 'Region.EU';
|
|
203
|
+
}
|
|
204
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGION_RE, region);
|
|
205
|
+
}
|
|
206
|
+
_fileManagement.FileManagement.writeFile(envFileName, envFileContent);
|
|
207
|
+
};
|
|
208
|
+
async function addPushNotificationFile(options, xcodeProject) {
|
|
209
|
+
const {
|
|
210
|
+
iosPath,
|
|
211
|
+
appName
|
|
212
|
+
} = options;
|
|
213
|
+
const file = 'PushService.swift';
|
|
214
|
+
const appPath = `${iosPath}/${appName}`;
|
|
215
|
+
const getTargetFile = filename => `${appPath}/${filename}`;
|
|
216
|
+
if (!_fileManagement.FileManagement.exists(getTargetFile(file))) {
|
|
217
|
+
_fileManagement.FileManagement.mkdir(appPath, {
|
|
218
|
+
recursive: true
|
|
219
|
+
});
|
|
220
|
+
const targetFile = getTargetFile(file);
|
|
221
|
+
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
|
|
222
|
+
} else {
|
|
223
|
+
console.log(`${getTargetFile(file)} already exists. Skipping...`);
|
|
224
|
+
}
|
|
225
|
+
const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');
|
|
226
|
+
const classesKey = xcodeProject.findPBXGroupKey({
|
|
227
|
+
name: `${appName}`
|
|
228
|
+
});
|
|
229
|
+
xcodeProject.addToPbxGroup(group, classesKey);
|
|
230
|
+
xcodeProject.addSourceFile(`${appName}/${file}`, null, group);
|
|
231
|
+
}
|
|
161
232
|
//# sourceMappingURL=withNotificationsXcodeProject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","appleTeamId","bundleIdentifier","bundleShortVersion","bundleVersion","iosPath","useFrameworks","appName","iosDeploymentTarget","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","injectCIONotificationPodfileCode","FileManagement","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","infoPlistTargetFile","updateNseInfoPlist","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","undefined","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","nseTarget","addTarget","addBuildPhase","configurations","pbxXCBuildConfigurationSection","buildSettings","PRODUCT_NAME","buildSettingsObj","DEVELOPMENT_TEAM","IPHONEOS_DEPLOYMENT_TARGET","CODE_SIGN_STYLE","SWIFT_VERSION","addTargetAttribute","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","projectName","platformProjectRoot","buildNumber","DEFAULT_BUNDLE_VERSION","payload","BUNDLE_SHORT_VERSION_RE","BUNDLE_VERSION_RE","plistFileString","readFile","replaceCodeByRegex"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n useFrameworks,\n appName,\n iosDeploymentTarget,\n } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n FileManagement.mkdir(`${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ];\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\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'] =\n 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'],\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 || '13.0';\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 FileManagement.writeFile(projPath, xcodeProject.writeSync());\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 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 appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\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"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AACA;AAEA;AAAmE;AAEnE,MAAMA,cAAc,GAAI,GAAEC,iCAA6B,aAAY;AAEnE,MAAM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H;EAEAgB,8BAAc,CAACyC,SAAS,CAACc,OAAO,CAAC7C,mBAAmB,EAAEgD,eAAe,CAAC;AACxE,CAAC"}
|
|
1
|
+
{"version":3,"names":["PLIST_FILENAME","CIO_NOTIFICATION_TARGET_NAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","iosPath","appName","projPath","xcodeProject","xcode","project","parse","err","Error","JSON","stringify","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","FileManagement","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","withXcodeProject","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","DEFAULT_BUNDLE_VERSION","injectCIONotificationPodfileCode","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","LOCAL_PATH_TO_CIO_NSE_FILES","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","objects","Object","keys","key","name","addToPbxGroup","uuid","projObjects","pbxTargetByName","console","warn","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","replaceCodeByRegex","envFileName","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","apiKey","region","file","appPath","exists","log","group","pbxCreateGroup","classesKey","findPBXGroupKey","addSourceFile"],"sources":["withNotificationsXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n CIO_NOTIFICATION_TARGET_NAME,\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { injectCIONotificationPodfileCode } from '../helpers/utils/injectCIOPodfileCode';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst PLIST_FILENAME = `${CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;\nconst ENV_FILENAME = 'Env.swift';\n\nconst TARGETED_DEVICE_FAMILY = `\"1,2\"`;\n\nconst addNotificationServiceExtension = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n // iosPath and appName are predefined from Expo config.\n // See function withCioNotificationsXcodeProject to get where the variabes are pulled from.\n const { iosPath, appName } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (options.pushNotification) {\n await addPushNotificationFile(options, xcodeProject);\n }\n\n if (options.pushNotification?.useRichPush) {\n await addRichPushXcodeProj(options, xcodeProject);\n }\n\n FileManagement.writeFile(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioNotificationsXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const {\n appleTeamId,\n iosDeploymentTarget,\n pushNotification,\n useFrameworks,\n } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js or app.json.'\n );\n\n // projectName and platformProjectRoot translates to appName and iosPath in addNotificationServiceExtension()\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js or app.json'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js or app.json'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js or app.json'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n useFrameworks,\n iosDeploymentTarget,\n pushNotification,\n };\n\n await addNotificationServiceExtension(options);\n\n return config;\n });\n};\n\nconst addRichPushXcodeProj = async (\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) => {\n const {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion,\n iosPath,\n iosDeploymentTarget,\n useFrameworks,\n } = options;\n\n await injectCIONotificationPodfileCode(iosPath, useFrameworks);\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\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 || '13.0';\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 SITE_ID_RE = /\\{\\{SITE_ID\\}\\}/;\n const API_KEY_RE = /\\{\\{API_KEY\\}\\}/;\n const REGION_RE = /\\{\\{REGION\\}\\}/;\n\n let envFileContent = FileManagement.readFile(envFileName);\n\n if (options.pushNotification?.env?.siteId) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n SITE_ID_RE,\n options.pushNotification?.env?.siteId\n );\n }\n\n if (options.pushNotification?.env?.apiKey) {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n API_KEY_RE,\n options.pushNotification?.env?.apiKey\n );\n }\n\n if (options.pushNotification?.env?.region) {\n let region = '';\n if (options.pushNotification?.env?.region === 'us') {\n region = 'Region.US';\n } else if (options.pushNotification?.env?.region === 'eu') {\n region = 'Region.EU';\n }\n envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n\n const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');\n const classesKey = xcodeProject.findPBXGroupKey({ name: `${appName}` });\n xcodeProject.addToPbxGroup(group, classesKey);\n\n xcodeProject.addSourceFile(`${appName}/${file}`, null, group);\n}\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAKA;AACA;AAEA;AAAmE;AAEnE,MAAMA,cAAc,GAAI,GAAEC,iCAA6B,aAAY;AACnE,MAAMC,YAAY,GAAG,WAAW;AAEhC,MAAMC,sBAAsB,GAAI,OAAM;AAEtC,MAAMC,+BAA+B,GAAG,MACtCC,OAAmC,IAChC;EACH;EACA;EACA,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAEpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,OAAQ,4BAA2B;EAElE,MAAME,YAAY,GAAGC,cAAK,CAACC,OAAO,CAACH,QAAQ,CAAC;EAE5CC,YAAY,CAACG,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAAA;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;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,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ph","require","runPostInstall","error"],"sources":["postInstall.js"],"sourcesContent":["try {\n const ph = require('./postInstallHelper');\n\n ph.runPostInstall();\n} catch (error) {}\n"],"mappings":";;AAAA,IAAI;EACF,MAAMA,EAAE,GAAGC,OAAO,CAAC,qBAAqB,CAAC;EAEzCD,EAAE,CAACE,cAAc,EAAE;AACrB,CAAC,CAAC,OAAOC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
function runPostInstall() {
|
|
5
|
+
// react native SDK package.json path
|
|
6
|
+
const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;
|
|
7
|
+
const expoPjsonFile = `${__dirname}/../package.json`;
|
|
8
|
+
try {
|
|
9
|
+
// if react native SDK is installed
|
|
10
|
+
if (fs.existsSync(rnPjsonFile)) {
|
|
11
|
+
const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');
|
|
12
|
+
expoPjson = require(expoPjsonFile);
|
|
13
|
+
const rnPackage = JSON.parse(rnPJson);
|
|
14
|
+
rnPackage.expoVersion = expoPjson.version;
|
|
15
|
+
fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {}
|
|
18
|
+
}
|
|
19
|
+
exports.runPostInstall = runPostInstall;
|
|
20
|
+
//# sourceMappingURL=postInstallHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fs","require","runPostInstall","rnPjsonFile","__dirname","expoPjsonFile","existsSync","rnPJson","readFileSync","expoPjson","rnPackage","JSON","parse","expoVersion","version","writeFileSync","stringify","error","exports"],"sources":["postInstallHelper.js"],"sourcesContent":["const fs = require('fs');\n\nfunction runPostInstall() {\n // react native SDK package.json path\n const rnPjsonFile = `${__dirname}/../../customerio-reactnative/package.json`;\n const expoPjsonFile = `${__dirname}/../package.json`;\n try {\n // if react native SDK is installed\n if (fs.existsSync(rnPjsonFile)) {\n const rnPJson = fs.readFileSync(rnPjsonFile, 'utf8');\n expoPjson = require(expoPjsonFile);\n\n const rnPackage = JSON.parse(rnPJson);\n rnPackage.expoVersion = expoPjson.version;\n\n\n fs.writeFileSync(rnPjsonFile, JSON.stringify(rnPackage, null, 2));\n }\n } catch (error) {}\n}\n\nexports.runPostInstall = runPostInstall;"],"mappings":";;AAAA,MAAMA,EAAE,GAAGC,OAAO,CAAC,IAAI,CAAC;AAExB,SAASC,cAAc,GAAG;EACxB;EACA,MAAMC,WAAW,GAAI,GAAEC,SAAU,4CAA2C;EAC5E,MAAMC,aAAa,GAAI,GAAED,SAAU,kBAAiB;EACpD,IAAI;IACF;IACA,IAAIJ,EAAE,CAACM,UAAU,CAACH,WAAW,CAAC,EAAE;MAC9B,MAAMI,OAAO,GAAGP,EAAE,CAACQ,YAAY,CAACL,WAAW,EAAE,MAAM,CAAC;MACpDM,SAAS,GAAGR,OAAO,CAACI,aAAa,CAAC;MAElC,MAAMK,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACL,OAAO,CAAC;MACrCG,SAAS,CAACG,WAAW,GAAGJ,SAAS,CAACK,OAAO;MAGzCd,EAAE,CAACe,aAAa,CAACZ,WAAW,EAAEQ,IAAI,CAACK,SAAS,CAACN,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnE;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE,CAAC;AACnB;AAEAC,OAAO,CAAChB,cAAc,GAAGA,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n
|
|
1
|
+
{"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["// properties set by the user in their app config file (e.g: app.json or app.plugin.js)\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n// Plugin options for pre-build\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n useFrameworks?: 'static' | 'dynamic';\n pushNotification?: {\n useRichPush: boolean;\n env: {\n siteId: string;\n apiKey: string;\n region: string;\n };\n };\n};\n\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n};\n\nexport type CustomerIOPluginOptions = {\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n"],"mappings":""}
|
|
@@ -4,19 +4,21 @@ export const withGoogleServicesJSON = (configOuter, cioProps) => {
|
|
|
4
4
|
return withProjectBuildGradle(configOuter, props => {
|
|
5
5
|
const options = {
|
|
6
6
|
androidPath: props.modRequest.platformProjectRoot,
|
|
7
|
-
|
|
7
|
+
googleServicesFile: cioProps === null || cioProps === void 0 ? void 0 : cioProps.googleServicesFile
|
|
8
8
|
};
|
|
9
9
|
const {
|
|
10
10
|
androidPath,
|
|
11
|
-
|
|
11
|
+
googleServicesFile
|
|
12
12
|
} = options;
|
|
13
13
|
if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {
|
|
14
|
-
if (
|
|
14
|
+
if (googleServicesFile && FileManagement.exists(googleServicesFile)) {
|
|
15
15
|
try {
|
|
16
|
-
FileManagement.copyFile(
|
|
16
|
+
FileManagement.copyFile(googleServicesFile, `${androidPath}/app/google-services.json`);
|
|
17
17
|
} catch (e) {
|
|
18
|
-
console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app
|
|
18
|
+
console.log(`There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
19
19
|
}
|
|
20
|
+
} else {
|
|
21
|
+
console.log(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`);
|
|
20
22
|
}
|
|
21
23
|
} else {
|
|
22
24
|
console.log(`File already exists: ${androidPath}/app/google-services.json. Skipping...`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","
|
|
1
|
+
{"version":3,"names":["withProjectBuildGradle","FileManagement","withGoogleServicesJSON","configOuter","cioProps","props","options","androidPath","modRequest","platformProjectRoot","googleServicesFile","exists","copyFile","e","console","log"],"sources":["withGoogleServicesJSON.ts"],"sourcesContent":["import { withProjectBuildGradle, ConfigPlugin } from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsAndroid } from './../types/cio-types';\n\nexport const withGoogleServicesJSON: ConfigPlugin<\n CustomerIOPluginOptionsAndroid\n> = (configOuter, cioProps) => {\n return withProjectBuildGradle(configOuter, (props) => {\n const options: CustomerIOPluginOptionsAndroid = {\n androidPath: props.modRequest.platformProjectRoot,\n googleServicesFile: cioProps?.googleServicesFile,\n };\n const { androidPath, googleServicesFile } = options;\n if (!FileManagement.exists(`${androidPath}/app/google-services.json`)) {\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${androidPath}/app/google-services.json`\n );\n } catch (e) {\n console.log(\n `There was an error copying your google-services.json file. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${androidPath}/app/google-services.json`\n );\n }\n } else {\n console.log(\n `File already exists: ${androidPath}/app/google-services.json. Skipping...`\n );\n }\n\n return props;\n });\n};\n"],"mappings":"AAAA,SAASA,sBAAsB,QAAsB,sBAAsB;AAE3E,SAASC,cAAc,QAAQ,mCAAmC;AAGlE,OAAO,MAAMC,sBAEZ,GAAG,CAACC,WAAW,EAAEC,QAAQ,KAAK;EAC7B,OAAOJ,sBAAsB,CAACG,WAAW,EAAGE,KAAK,IAAK;IACpD,MAAMC,OAAuC,GAAG;MAC9CC,WAAW,EAAEF,KAAK,CAACG,UAAU,CAACC,mBAAmB;MACjDC,kBAAkB,EAAEN,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM;IAChC,CAAC;IACD,MAAM;MAAEH,WAAW;MAAEG;IAAmB,CAAC,GAAGJ,OAAO;IACnD,IAAI,CAACL,cAAc,CAACU,MAAM,CAAE,GAAEJ,WAAY,2BAA0B,CAAC,EAAE;MACrE,IAAIG,kBAAkB,IAAIT,cAAc,CAACU,MAAM,CAACD,kBAAkB,CAAC,EAAE;QACnE,IAAI;UACFT,cAAc,CAACW,QAAQ,CACrBF,kBAAkB,EACjB,GAAEH,WAAY,2BAA0B,CAC1C;QACH,CAAC,CAAC,OAAOM,CAAC,EAAE;UACVC,OAAO,CAACC,GAAG,CACR,4FAA2FR,WAAY,2BAA0B,CACnI;QACH;MACF,CAAC,MAAM;QACLO,OAAO,CAACC,GAAG,CACR,wCAAuCL,kBAAmB,yDAAwDH,WAAY,2BAA0B,CAC1J;MACH;IACF,CAAC,MAAM;MACLO,OAAO,CAACC,GAAG,CACR,wBAAuBR,WAAY,wCAAuC,CAC5E;IACH;IAEA,OAAOF,KAAK;EACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
|
|
2
2
|
export const IOS_DEPLOYMENT_TARGET = '13.0';
|
|
3
|
-
export const CIO_SDK_VERSION = '
|
|
3
|
+
export const CIO_SDK_VERSION = '~> 2.0.0';
|
|
4
4
|
export const CIO_PODFILE_REGEX = /pod 'CustomerIO\/MessagingPushAPN'/;
|
|
5
5
|
export const CIO_CIO_TARGET_REGEX = /cio_target_names/;
|
|
6
6
|
export const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
|
|
7
|
+
export const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \|installer\|/;
|
|
7
8
|
export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
|
|
8
9
|
export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
|
|
9
10
|
export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
|
|
10
|
-
export const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \|installer\|/;
|
|
11
11
|
export const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = /(- \(BOOL\)application:\(UIApplication \*\)application didFinishLaunchingWithOptions:\(NSDictionary \*\)launchOptions(\s|\n)*?\{)((.|\n)*)\[super(\s)application:application(\s)didFinishLaunchingWithOptions:launchOptions\];/;
|
|
12
12
|
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = /return \[super application:application didFailToRegisterForRemoteNotificationsWithError:error\];/;
|
|
13
13
|
export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = /(- \(void\)application:\(UIApplication \*\)application didFailToRegisterForRemoteNotificationsWithError:\(NSError \*\)error(\s|\n)*?\{)(.|\n){2}.*\n\}/;
|
|
@@ -32,9 +32,6 @@ export const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `
|
|
|
32
32
|
export const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `
|
|
33
33
|
return [pnHandlerObj application:application deviceToken:deviceToken];
|
|
34
34
|
`;
|
|
35
|
-
|
|
36
|
-
// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method
|
|
37
|
-
// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push
|
|
38
35
|
export const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `
|
|
39
36
|
// Register for push notifications
|
|
40
37
|
[pnHandlerObj registerPushNotification:self];
|
|
@@ -52,7 +49,7 @@ export const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `
|
|
|
52
49
|
- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
53
50
|
completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);
|
|
54
51
|
}`;
|
|
55
|
-
export const CIO_PODFILE_SNIPPET = ` pod 'CustomerIO/MessagingPushAPN', '
|
|
52
|
+
export const CIO_PODFILE_SNIPPET = ` pod 'CustomerIO/MessagingPushAPN', '${CIO_SDK_VERSION}'`;
|
|
56
53
|
export const CIO_PODFILE_NOTIFICATION_SNIPPET = `
|
|
57
54
|
target '${CIO_NOTIFICATION_TARGET_NAME}' do
|
|
58
55
|
${CIO_PODFILE_SNIPPET}
|
|
@@ -62,45 +59,4 @@ target '${CIO_NOTIFICATION_TARGET_NAME}' do
|
|
|
62
59
|
use_frameworks! :linkage => :static
|
|
63
60
|
${CIO_PODFILE_SNIPPET}
|
|
64
61
|
end`;
|
|
65
|
-
export const CIO_PODFILE_TARGET_NAMES_SNIPPET = `
|
|
66
|
-
cio_target_names = [
|
|
67
|
-
'CustomerIOTracking',
|
|
68
|
-
'CustomerIOCommon',
|
|
69
|
-
'CustomerIOMessagingPushAPN',
|
|
70
|
-
'CustomerIOMessagingPush'
|
|
71
|
-
]`;
|
|
72
|
-
export const CIO_PODFILE_POST_INSTALL_SNIPPET = `
|
|
73
|
-
installer.pods_project.targets.each do |target|
|
|
74
|
-
if cio_target_names.include? target.name
|
|
75
|
-
puts "Modifying target #{target.name}"
|
|
76
|
-
|
|
77
|
-
target.build_configurations.each do |config|
|
|
78
|
-
puts "Setting build config settings for #{target.name}"
|
|
79
|
-
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end`;
|
|
83
|
-
export const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `
|
|
84
|
-
cio_target_names = [
|
|
85
|
-
'CustomerIOTracking',
|
|
86
|
-
'CustomerIOCommon',
|
|
87
|
-
'CustomerIOMessagingPushAPN',
|
|
88
|
-
'CustomerIOMessagingPush'
|
|
89
|
-
]
|
|
90
|
-
|
|
91
|
-
post_install do |installer|
|
|
92
|
-
|
|
93
|
-
installer.pods_project.targets.each do |target|
|
|
94
|
-
if cio_target_names.include? target.name
|
|
95
|
-
puts "Modifying target #{target.name}"
|
|
96
|
-
|
|
97
|
-
target.build_configurations.each do |config|
|
|
98
|
-
puts "Setting build config settings for #{target.name}"
|
|
99
|
-
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
react_native_post_install(installer)
|
|
104
|
-
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
|
105
|
-
end`;
|
|
106
62
|
//# sourceMappingURL=ios.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_SDK_VERSION","CIO_PODFILE_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","
|
|
1
|
+
{"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_SDK_VERSION","CIO_PODFILE_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_SDK_VERSION = '~> 2.0.0';\nexport const CIO_PODFILE_REGEX = /pod 'CustomerIO\\/MessagingPushAPN'/;\nexport const CIO_CIO_TARGET_REGEX = /cio_target_names/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_PODFILE_SNIPPET = ` pod 'CustomerIO/MessagingPushAPN', '${CIO_SDK_VERSION}'`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n${CIO_PODFILE_SNIPPET}\nend`;\nexport const CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n use_frameworks! :linkage => :static\n${CIO_PODFILE_SNIPPET}\nend`;\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAC7G,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,eAAe,GAAG,UAAU;AACzC,OAAO,MAAMC,iBAAiB,GAAG,oCAAoC;AACrE,OAAO,MAAMC,oBAAoB,GAAG,kBAAkB;AACtD,OAAO,MAAMC,8BAA8B,GAAG,iCAAiC;AAC/E,OAAO,MAAMC,8BAA8B,GAAG,+BAA+B;AAC7E,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,kCAAkC,GAC7C,gOAAgO;AAElO,OAAO,MAAMC,0DAA0D,GACrE,kGAAkG;AAEpG,OAAO,MAAMC,8DAA8D,GACzE,wJAAwJ;AAE1J,OAAO,MAAMC,0DAA0D,GACrE,wGAAwG;AAE1G,OAAO,MAAMC,gCAAgC,GAC3C,mCAAmC;AAErC,OAAO,MAAMC,2BAA2B,GACtC,mEAAmE;AACrE,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AACzC,OAAO,MAAMC,4BAA4B,GAAG,KAAK;AACjD,OAAO,MAAMC,eAAe,GAAG,eAAe;AAC9C,OAAO,MAAMC,4BAA4B,GAAG,qBAAqB;AACjE,OAAO,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAED,OAAO,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AACA,OAAO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AACF,OAAO,MAAMC,mBAAmB,GAAI,yCAAwCzB,eAAgB,GAAE;AAC9F,OAAO,MAAM0B,gCAAgC,GAAI;AACjD,UAAUT,4BAA6B;AACvC,EAAEQ,mBAAoB;AACtB,IAAI;AACJ,OAAO,MAAME,iDAAiD,GAAI;AAClE,UAAUV,4BAA6B;AACvC;AACA,EAAEQ,mBAAoB;AACtB,IAAI"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import UserNotifications
|
|
3
|
-
import
|
|
3
|
+
import CioTracking
|
|
4
|
+
import CioMessagingPushAPN
|
|
4
5
|
|
|
5
6
|
@objc
|
|
6
7
|
public class NotificationServiceCioManager : NSObject {
|
|
@@ -9,6 +10,8 @@ public class NotificationServiceCioManager : NSObject {
|
|
|
9
10
|
|
|
10
11
|
@objc(didReceive:withContentHandler:)
|
|
11
12
|
public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
13
|
+
CustomerIO
|
|
14
|
+
.initialize(siteId: Env.customerIOSiteId, apiKey: Env.customerIOApiKey, region: Env.customerIORegion) { config in }
|
|
12
15
|
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
13
16
|
}
|
|
14
17
|
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET,
|
|
1
|
+
import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET, CIO_PODFILE_NOTIFICATION_SNIPPET, CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET, CIO_PODFILE_NOTIFICATION_REGEX, CIO_CIO_TARGET_REGEX, CIO_PODFILE_POST_INSTALL_REGEX } from '../constants/ios';
|
|
2
2
|
import { FileManagement } from './fileManagement';
|
|
3
3
|
export async function injectCIOPodfileCode(iosPath) {
|
|
4
4
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -10,9 +10,7 @@ export async function injectCIOPodfileCode(iosPath) {
|
|
|
10
10
|
const index = lines.findIndex(line => CIO_PODFILE_POST_INSTALL_REGEX.test(line));
|
|
11
11
|
let content = lines;
|
|
12
12
|
if (index > -1) {
|
|
13
|
-
content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '',
|
|
14
|
-
} else {
|
|
15
|
-
content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
|
|
13
|
+
content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '', ...lines.slice(index - 1)];
|
|
16
14
|
}
|
|
17
15
|
FileManagement.write(filename, content.join('\n'));
|
|
18
16
|
} else {
|