customerio-expo-plugin 1.0.0-beta.2 → 1.0.0-beta.3

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 CHANGED
@@ -122,7 +122,7 @@ The `customerio-expo-plugin` supports the following configuration options. In mo
122
122
  <td><code>android.googleServicesFile</code></td>
123
123
  <td>string</td>
124
124
  <td><code>undefined</code></td>
125
- <td>Set the path to the folder that contains your <code>google-services.json</code> file with a trailing slash (<code>/</code>).</td>
125
+ <td>Set the path to your <code>google-services.json</code> file.</td>
126
126
  </tr>
127
127
  <tr>
128
128
  <td><code>ios.pushNotification</code></td>
@@ -136,6 +136,12 @@ The `customerio-expo-plugin` supports the following configuration options. In mo
136
136
  <td><code>false</code></td>
137
137
  <td>Enables rich push for iOS</td>
138
138
  </tr>
139
+ <tr>
140
+ <td style="white-space:nowrap;"><code>ios.pushNotification.env</code></td>
141
+ <td>object</td>
142
+ <td><code>undefined</code></td>
143
+ <td>Set environment variables to use for rich push workaround. This field should be filled when enabling rich push. Expected values: `siteId`: `string`,`apiKey`: `string`, `region`: `us` or `eu`</td>
144
+ </tr>
139
145
  <tr>
140
146
  <td style="white-space:nowrap;"><code>ios.useFrameworks</code></td>
141
147
  <td>string</td>
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LOCAL_PATH_TO_CIO_NSE_FILES = exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = exports.CIO_TARGET_NAME = exports.CIO_SDK_VERSION = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_PODFILE_SNIPPET = exports.CIO_PODFILE_REGEX = exports.CIO_PODFILE_POST_INSTALL_REGEX = exports.CIO_PODFILE_NOTIFICATION_STATIC_FRAMEWORK_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_SNIPPET = exports.CIO_PODFILE_NOTIFICATION_REGEX = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_CIO_TARGET_REGEX = exports.CIO_APPDELEGATEHEADER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
7
- const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
7
+ const LOCAL_PATH_TO_CIO_NSE_FILES = `./node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
8
8
  exports.LOCAL_PATH_TO_CIO_NSE_FILES = LOCAL_PATH_TO_CIO_NSE_FILES;
9
9
  const IOS_DEPLOYMENT_TARGET = '13.0';
10
10
  exports.IOS_DEPLOYMENT_TARGET = IOS_DEPLOYMENT_TARGET;
@@ -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","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 => :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AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAAC;AACI,MAAMC,mBAAmB,GAAI,yCAAwCzB,eAAgB,GAAE;AAAC;AACxF,MAAM0B,gCAAgC,GAAI;AACjD,UAAUT,4BAA6B;AACvC,EAAEQ,mBAAoB;AACtB,IAAI;AAAC;AACE,MAAME,iDAAiD,GAAI;AAClE,UAAUV,4BAA6B;AACvC;AACA,EAAEQ,mBAAoB;AACtB,IAAI;AAAC"}
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":";;;;;;AAAO,MAAMA,2BAA2B,GAAI,oEAAmE;AAAC;AACzG,MAAMC,qBAAqB,GAAG,MAAM;AAAC;AACrC,MAAMC,eAAe,GAAG,UAAU;AAAC;AACnC,MAAMC,iBAAiB,GAAG,oCAAoC;AAAC;AAC/D,MAAMC,oBAAoB,GAAG,kBAAkB;AAAC;AAChD,MAAMC,8BAA8B,GAAG,iCAAiC;AAAC;AACzE,MAAMC,8BAA8B,GAAG,+BAA+B;AAAC;AACvE,MAAMC,+BAA+B,GAAG,wBAAwB;AAAC;AACjE,MAAMC,mCAAmC,GAAG,4BAA4B;AAAC;AACzE,MAAMC,6BAA6B,GAAG,sBAAsB;AAAC;AAC7D,MAAMC,kCAAkC,GAC7C,gOAAgO;AAAC;AAE5N,MAAMC,0DAA0D,GACrE,kGAAkG;AAAC;AAE9F,MAAMC,8DAA8D,GACzE,wJAAwJ;AAAC;AAEpJ,MAAMC,0DAA0D,GACrE,wGAAwG;AAAC;AAEpG,MAAMC,gCAAgC,GAC3C,mCAAmC;AAAC;AAE/B,MAAMC,2BAA2B,GACtC,mEAAmE;AAAC;AAC/D,MAAMC,sBAAsB,GAAG,GAAG;AAAC;AACnC,MAAMC,4BAA4B,GAAG,KAAK;AAAC;AAC3C,MAAMC,eAAe,GAAG,eAAe;AAAC;AACxC,MAAMC,4BAA4B,GAAG,qBAAqB;AAAC;AAC3D,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAAC;AAEK,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAAC;AAEK,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAAC;AAEK,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AAAA;AACO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AAAA;AACO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AAAC;AACI,MAAMC,mBAAmB,GAAI,yCAAwCzB,eAAgB,GAAE;AAAC;AACxF,MAAM0B,gCAAgC,GAAI;AACjD,UAAUT,4BAA6B;AACvC,EAAEQ,mBAAoB;AACtB,IAAI;AAAC;AACE,MAAME,iDAAiD,GAAI;AAClE,UAAUV,4BAA6B;AACvC;AACA,EAAEQ,mBAAoB;AACtB,IAAI;AAAC"}
@@ -97,6 +97,13 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
97
97
  useFrameworks
98
98
  } = options;
99
99
  await (0, _injectCIOPodfileCode.injectCIONotificationPodfileCode)(iosPath, useFrameworks);
100
+
101
+ // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
102
+ // If true then skip creating a new group to avoid duplicate folders
103
+ if (xcodeProject.pbxTargetByName(_ios.CIO_NOTIFICATION_TARGET_NAME)) {
104
+ console.warn(`${_ios.CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
105
+ return;
106
+ }
100
107
  const nsePath = `${iosPath}/${_ios.CIO_NOTIFICATION_TARGET_NAME}`;
101
108
  _fileManagement.FileManagement.mkdir(nsePath, {
102
109
  recursive: true
@@ -124,7 +131,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
124
131
  // files / folder appear in the file explorer in Xcode.
125
132
  const groups = xcodeProject.hash.project.objects['PBXGroup'];
126
133
  Object.keys(groups).forEach(key => {
127
- if (groups[key].name === undefined) {
134
+ if (groups[key].name === undefined && groups[key].path === undefined) {
128
135
  xcodeProject.addToPbxGroup(extGroup.uuid, key);
129
136
  }
130
137
  });
@@ -194,14 +201,19 @@ const updateNseEnv = (options, envFileName) => {
194
201
  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
202
  }
196
203
  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';
204
+ var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14;
205
+ const regionMap = {
206
+ us: 'Region.US',
207
+ eu: 'Region.EU'
208
+ };
209
+ const region = (_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : (_options$pushNotifica14 = _options$pushNotifica13.region) === null || _options$pushNotifica14 === void 0 ? void 0 : _options$pushNotifica14.toLowerCase();
210
+ const mappedRegion = regionMap[region] || '';
211
+ if (!mappedRegion) {
212
+ var _options$pushNotifica15, _options$pushNotifica16;
213
+ console.warn(`${(_options$pushNotifica15 = options.pushNotification) === null || _options$pushNotifica15 === void 0 ? void 0 : (_options$pushNotifica16 = _options$pushNotifica15.env) === null || _options$pushNotifica16 === void 0 ? void 0 : _options$pushNotifica16.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
214
+ } else {
215
+ envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGION_RE, mappedRegion);
203
216
  }
204
- envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, REGION_RE, region);
205
217
  }
206
218
  _fileManagement.FileManagement.writeFile(envFileName, envFileContent);
207
219
  };
@@ -213,6 +225,9 @@ async function addPushNotificationFile(options, xcodeProject) {
213
225
  const file = 'PushService.swift';
214
226
  const appPath = `${iosPath}/${appName}`;
215
227
  const getTargetFile = filename => `${appPath}/${filename}`;
228
+
229
+ // Check whether {file} exists in the project. If false, then add the file
230
+ // If {file} exists then skip and return
216
231
  if (!_fileManagement.FileManagement.exists(getTargetFile(file))) {
217
232
  _fileManagement.FileManagement.mkdir(appPath, {
218
233
  recursive: true
@@ -221,6 +236,7 @@ async function addPushNotificationFile(options, xcodeProject) {
221
236
  _fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
222
237
  } else {
223
238
  console.log(`${getTargetFile(file)} already exists. Skipping...`);
239
+ return;
224
240
  }
225
241
  const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');
226
242
  const classesKey = xcodeProject.findPBXGroupKey({
@@ -1 +1 @@
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;IACtE;IAEA,IAAIR,OAAO,CAACY,gBAAgB,EAAE;MAC5B,MAAMC,uBAAuB,CAACb,OAAO,EAAEI,YAAY,CAAC;IACtD;IAEA,6BAAIJ,OAAO,CAACY,gBAAgB,kDAAxB,sBAA0BE,WAAW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AAS,CAACqE,WAAW,EAAEI,cAAc,CAAC;AACvD,CAAC;AAED,eAAe7E,uBAAuB,CACpCb,OAAmC,EACnCI,YAAiB,EACjB;EACA,MAAM;IAAEH,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAM+F,IAAI,GAAG,mBAAmB;EAChC,MAAMC,OAAO,GAAI,GAAE/F,OAAQ,IAAGC,OAAQ,EAAC;EACvC,MAAMyC,aAAa,GAAIC,QAAgB,IAAM,GAAEoD,OAAQ,IAAGpD,QAAS,EAAC;EAEpE,IAAI,CAAC5B,8BAAc,CAACiF,MAAM,CAACtD,aAAa,CAACoD,IAAI,CAAC,CAAC,EAAE;IAC/C/E,8BAAc,CAACwB,KAAK,CAACwD,OAAO,EAAE;MAC5BvD,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMK,UAAU,GAAGH,aAAa,CAACoD,IAAI,CAAC;IACtC/E,8BAAc,CAAC+B,QAAQ,CACpB,GAAEC,gCAA4B,IAAG+C,IAAK,EAAC,EACxCjD,UAAU,CACX;EACH,CAAC,MAAM;IACLmB,OAAO,CAACiC,GAAG,CAAE,GAAEvD,aAAa,CAACoD,IAAI,CAAE,8BAA6B,CAAC;EACnE;EAEA,MAAMI,KAAK,GAAG/F,YAAY,CAACgG,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAGjG,YAAY,CAACkG,eAAe,CAAC;IAAE1C,IAAI,EAAG,GAAE1D,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAACyD,aAAa,CAACsC,KAAK,EAAEE,UAAU,CAAC;EAE7CjG,YAAY,CAACmG,aAAa,CAAE,GAAErG,OAAQ,IAAG6F,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
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","pbxTargetByName","console","warn","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","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","replaceCodeByRegex","envFileName","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","apiKey","region","regionMap","us","eu","toLowerCase","mappedRegion","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 // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '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 const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n 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 return;\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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,UAAU,GAAGH,aAAa,CAACuD,IAAI,CAAC;IACtCrF,8BAAc,CAACkC,QAAQ,CACpB,GAAEC,gCAA4B,IAAGkD,IAAK,EAAC,EACxCpD,UAAU,CACX;EACH,CAAC,MAAM;IACLT,OAAO,CAACgE,GAAG,CAAE,GAAE1D,aAAa,CAACuD,IAAI,CAAE,8BAA6B,CAAC;IACjE;EACF;EAEA,MAAMI,KAAK,GAAGrG,YAAY,CAACsG,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAGvG,YAAY,CAACwG,eAAe,CAAC;IAAE7C,IAAI,EAAG,GAAE7D,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAAC6D,aAAa,CAACwC,KAAK,EAAEE,UAAU,CAAC;EAE7CvG,YAAY,CAACyG,aAAa,CAAE,GAAE3G,OAAQ,IAAGmG,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
@@ -1,4 +1,4 @@
1
- export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
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
3
  export const CIO_SDK_VERSION = '~> 2.0.0';
4
4
  export const CIO_PODFILE_REGEX = /pod 'CustomerIO\/MessagingPushAPN'/;
@@ -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","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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ACJ,OAAO,MAAME,iDAAiD,GAAI;AAClE,UAAUV,4BAA6B;AACvC;AACA,EAAEQ,mBAAoB;AACtB,IAAI"}
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,oEAAmE;AAC/G,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"}
@@ -89,6 +89,13 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
89
89
  useFrameworks
90
90
  } = options;
91
91
  await injectCIONotificationPodfileCode(iosPath, useFrameworks);
92
+
93
+ // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
94
+ // If true then skip creating a new group to avoid duplicate folders
95
+ if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
96
+ console.warn(`${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`);
97
+ return;
98
+ }
92
99
  const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;
93
100
  FileManagement.mkdir(nsePath, {
94
101
  recursive: true
@@ -116,7 +123,7 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
116
123
  // files / folder appear in the file explorer in Xcode.
117
124
  const groups = xcodeProject.hash.project.objects['PBXGroup'];
118
125
  Object.keys(groups).forEach(key => {
119
- if (groups[key].name === undefined) {
126
+ if (groups[key].name === undefined && groups[key].path === undefined) {
120
127
  xcodeProject.addToPbxGroup(extGroup.uuid, key);
121
128
  }
122
129
  });
@@ -186,14 +193,19 @@ const updateNseEnv = (options, envFileName) => {
186
193
  envFileContent = replaceCodeByRegex(envFileContent, API_KEY_RE, (_options$pushNotifica8 = options.pushNotification) === null || _options$pushNotifica8 === void 0 ? void 0 : (_options$pushNotifica9 = _options$pushNotifica8.env) === null || _options$pushNotifica9 === void 0 ? void 0 : _options$pushNotifica9.apiKey);
187
194
  }
188
195
  if ((_options$pushNotifica10 = options.pushNotification) !== null && _options$pushNotifica10 !== void 0 && (_options$pushNotifica11 = _options$pushNotifica10.env) !== null && _options$pushNotifica11 !== void 0 && _options$pushNotifica11.region) {
189
- var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14, _options$pushNotifica15;
190
- let region = '';
191
- 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') {
192
- region = 'Region.US';
193
- } 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') {
194
- region = 'Region.EU';
196
+ var _options$pushNotifica12, _options$pushNotifica13, _options$pushNotifica14;
197
+ const regionMap = {
198
+ us: 'Region.US',
199
+ eu: 'Region.EU'
200
+ };
201
+ const region = (_options$pushNotifica12 = options.pushNotification) === null || _options$pushNotifica12 === void 0 ? void 0 : (_options$pushNotifica13 = _options$pushNotifica12.env) === null || _options$pushNotifica13 === void 0 ? void 0 : (_options$pushNotifica14 = _options$pushNotifica13.region) === null || _options$pushNotifica14 === void 0 ? void 0 : _options$pushNotifica14.toLowerCase();
202
+ const mappedRegion = regionMap[region] || '';
203
+ if (!mappedRegion) {
204
+ var _options$pushNotifica15, _options$pushNotifica16;
205
+ console.warn(`${(_options$pushNotifica15 = options.pushNotification) === null || _options$pushNotifica15 === void 0 ? void 0 : (_options$pushNotifica16 = _options$pushNotifica15.env) === null || _options$pushNotifica16 === void 0 ? void 0 : _options$pushNotifica16.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`);
206
+ } else {
207
+ envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, mappedRegion);
195
208
  }
196
- envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);
197
209
  }
198
210
  FileManagement.writeFile(envFileName, envFileContent);
199
211
  };
@@ -205,6 +217,9 @@ async function addPushNotificationFile(options, xcodeProject) {
205
217
  const file = 'PushService.swift';
206
218
  const appPath = `${iosPath}/${appName}`;
207
219
  const getTargetFile = filename => `${appPath}/${filename}`;
220
+
221
+ // Check whether {file} exists in the project. If false, then add the file
222
+ // If {file} exists then skip and return
208
223
  if (!FileManagement.exists(getTargetFile(file))) {
209
224
  FileManagement.mkdir(appPath, {
210
225
  recursive: true
@@ -213,6 +228,7 @@ async function addPushNotificationFile(options, xcodeProject) {
213
228
  FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
214
229
  } else {
215
230
  console.log(`${getTargetFile(file)} already exists. Skipping...`);
231
+ return;
216
232
  }
217
233
  const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');
218
234
  const classesKey = xcodeProject.findPBXGroupKey({
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","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","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,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEN,4BAA6B,aAAY;AACnE,MAAMO,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,GAAGf,KAAK,CAACgB,OAAO,CAACF,QAAQ,CAAC;EAE5CC,YAAY,CAACE,KAAK,CAAC,gBAAgBC,GAAU,EAAE;IAAA;IAC7C,IAAIA,GAAG,EAAE;MACP,MAAM,IAAIC,KAAK,CAAE,8BAA6BC,IAAI,CAACC,SAAS,CAACH,GAAG,CAAE,EAAC,CAAC;IACtE;IAEA,IAAIP,OAAO,CAACW,gBAAgB,EAAE;MAC5B,MAAMC,uBAAuB,CAACZ,OAAO,EAAEI,YAAY,CAAC;IACtD;IAEA,6BAAIJ,OAAO,CAACW,gBAAgB,kDAAxB,sBAA0BE,WAAW,EAAE;MACzC,MAAMC,oBAAoB,CAACd,OAAO,EAAEI,YAAY,CAAC;IACnD;IAEAT,cAAc,CAACoB,SAAS,CAACZ,QAAQ,EAAEC,YAAY,CAACY,SAAS,EAAE,CAA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ACpC,MAAMwF,IAAI,GAAG,mBAAmB;EAChC,MAAMC,OAAO,GAAI,GAAExF,OAAQ,IAAGC,OAAQ,EAAC;EACvC,MAAMoC,aAAa,GAAIC,QAAgB,IAAM,GAAEkD,OAAQ,IAAGlD,QAAS,EAAC;EAEpE,IAAI,CAAC5C,cAAc,CAAC+F,MAAM,CAACpD,aAAa,CAACkD,IAAI,CAAC,CAAC,EAAE;IAC/C7F,cAAc,CAACwC,KAAK,CAACsD,OAAO,EAAE;MAC5BrD,SAAS,EAAE;IACb,CAAC,CAAC;IAEF,MAAMK,UAAU,GAAGH,aAAa,CAACkD,IAAI,CAAC;IACtC7F,cAAc,CAAC+C,QAAQ,CACpB,GAAElD,2BAA4B,IAAGgG,IAAK,EAAC,EACxC/C,UAAU,CACX;EACH,CAAC,MAAM;IACLkB,OAAO,CAACgC,GAAG,CAAE,GAAErD,aAAa,CAACkD,IAAI,CAAE,8BAA6B,CAAC;EACnE;EAEA,MAAMI,KAAK,GAAGxF,YAAY,CAACyF,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAG1F,YAAY,CAAC2F,eAAe,CAAC;IAAEzC,IAAI,EAAG,GAAEpD,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAACmD,aAAa,CAACqC,KAAK,EAAEE,UAAU,CAAC;EAE7C1F,YAAY,CAAC4F,aAAa,CAAE,GAAE9F,OAAQ,IAAGsF,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
1
+ {"version":3,"names":["withXcodeProject","xcode","CIO_NOTIFICATION_TARGET_NAME","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","replaceCodeByRegex","injectCIONotificationPodfileCode","FileManagement","PLIST_FILENAME","ENV_FILENAME","TARGETED_DEVICE_FAMILY","addNotificationServiceExtension","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","pushNotification","addPushNotificationFile","useRichPush","addRichPushXcodeProj","writeFile","writeSync","withCioNotificationsXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","useFrameworks","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion","pbxTargetByName","console","warn","nsePath","mkdir","recursive","files","getTargetFile","filename","forEach","targetFile","copyFile","infoPlistTargetFile","updateNseInfoPlist","updateNseEnv","extGroup","addPbxGroup","groups","hash","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","envFileName","SITE_ID_RE","API_KEY_RE","REGION_RE","envFileContent","env","siteId","apiKey","region","regionMap","us","eu","toLowerCase","mappedRegion","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 // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project\n // If true then skip creating a new group to avoid duplicate folders\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;\n FileManagement.mkdir(nsePath, {\n recursive: true,\n });\n\n const files = [\n PLIST_FILENAME,\n 'NotificationService.h',\n 'NotificationService.swift',\n 'NotificationService.m',\n ENV_FILENAME,\n ];\n\n const getTargetFile = (filename: string) => `${nsePath}/${filename}`;\n\n files.forEach((filename) => {\n const targetFile = getTargetFile(filename);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`,\n targetFile\n );\n });\n\n /* MODIFY COPIED EXTENSION FILES */\n const infoPlistTargetFile = getTargetFile(PLIST_FILENAME);\n updateNseInfoPlist({\n bundleVersion,\n bundleShortVersion,\n infoPlistTargetFile,\n });\n updateNseEnv(options, getTargetFile(ENV_FILENAME));\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup(\n files,\n CIO_NOTIFICATION_TARGET_NAME,\n CIO_NOTIFICATION_TARGET_NAME\n );\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined && groups[key].path === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {\n console.warn(\n `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`\n );\n return;\n }\n\n // Add the NSE target\n // This also adds PBXTargetDependency and PBXContainerItemProxy\n const nseTarget = xcodeProject.addTarget(\n CIO_NOTIFICATION_TARGET_NAME,\n 'app_extension',\n CIO_NOTIFICATION_TARGET_NAME,\n `${bundleIdentifier}.richpush`\n );\n\n // Add build phases to the new target\n xcodeProject.addBuildPhase(\n ['NotificationService.m', 'NotificationService.swift', 'Env.swift'],\n 'PBXSourcesBuildPhase',\n 'Sources',\n nseTarget.uuid\n );\n xcodeProject.addBuildPhase(\n [],\n 'PBXResourcesBuildPhase',\n 'Resources',\n nseTarget.uuid\n );\n\n xcodeProject.addBuildPhase(\n [],\n 'PBXFrameworksBuildPhase',\n 'Frameworks',\n nseTarget.uuid\n );\n\n // Edit the Deployment info of the target\n const configurations = xcodeProject.pbxXCBuildConfigurationSection();\n for (const key in configurations) {\n if (\n typeof configurations[key].buildSettings !== 'undefined' &&\n configurations[key].buildSettings.PRODUCT_NAME ===\n `\"${CIO_NOTIFICATION_TARGET_NAME}\"`\n ) {\n const buildSettingsObj = configurations[key].buildSettings;\n buildSettingsObj.DEVELOPMENT_TEAM = appleTeamId;\n buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =\n iosDeploymentTarget || '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 const regionMap = {\n us: 'Region.US',\n eu: 'Region.EU',\n };\n const region = options.pushNotification?.env?.region?.toLowerCase();\n const mappedRegion = (regionMap as any)[region] || '';\n if (!mappedRegion) {\n console.warn(\n `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`\n );\n } else {\n envFileContent = replaceCodeByRegex(\n envFileContent,\n REGION_RE,\n mappedRegion\n );\n }\n }\n\n FileManagement.writeFile(envFileName, envFileContent);\n};\n\nasync function addPushNotificationFile(\n options: CustomerIOPluginOptionsIOS,\n xcodeProject: any\n) {\n const { iosPath, appName } = options;\n const file = 'PushService.swift';\n const appPath = `${iosPath}/${appName}`;\n const getTargetFile = (filename: string) => `${appPath}/${filename}`;\n\n // Check whether {file} exists in the project. If false, then add the file\n // If {file} exists then skip and return\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(appPath, {\n recursive: true,\n });\n\n 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 return;\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,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,4BAA4B,EAC5BC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AACjC,SAASC,kBAAkB,QAAQ,gCAAgC;AACnE,SAASC,gCAAgC,QAAQ,uCAAuC;AAExF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,cAAc,GAAI,GAAEN,4BAA6B,aAAY;AACnE,MAAMO,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,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AEF,MAAMK,UAAU,GAAGH,aAAa,CAACqD,IAAI,CAAC;IACtCnG,cAAc,CAACkD,QAAQ,CACpB,GAAErD,2BAA4B,IAAGsG,IAAK,EAAC,EACxClD,UAAU,CACX;EACH,CAAC,MAAM;IACLT,OAAO,CAAC8D,GAAG,CAAE,GAAExD,aAAa,CAACqD,IAAI,CAAE,8BAA6B,CAAC;IACjE;EACF;EAEA,MAAMI,KAAK,GAAG9F,YAAY,CAAC+F,cAAc,CAAC,yBAAyB,CAAC;EACpE,MAAMC,UAAU,GAAGhG,YAAY,CAACiG,eAAe,CAAC;IAAE5C,IAAI,EAAG,GAAEvD,OAAQ;EAAE,CAAC,CAAC;EACvEE,YAAY,CAACuD,aAAa,CAACuC,KAAK,EAAEE,UAAU,CAAC;EAE7ChG,YAAY,CAACkG,aAAa,CAAE,GAAEpG,OAAQ,IAAG4F,IAAK,EAAC,EAAE,IAAI,EAAEI,KAAK,CAAC;AAC/D"}
@@ -1,4 +1,4 @@
1
- export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
1
+ export declare const LOCAL_PATH_TO_CIO_NSE_FILES = "./node_modules/customerio-expo-plugin/src/helpers/native-files/ios";
2
2
  export declare const IOS_DEPLOYMENT_TARGET = "13.0";
3
3
  export declare const CIO_SDK_VERSION = "~> 2.0.0";
4
4
  export declare const CIO_PODFILE_REGEX: RegExp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Expo config plugin for the Customer IO React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,4 +1,4 @@
1
- export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
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
3
  export const CIO_SDK_VERSION = '~> 2.0.0';
4
4
  export const CIO_PODFILE_REGEX = /pod 'CustomerIO\/MessagingPushAPN'/;
@@ -117,6 +117,15 @@ const addRichPushXcodeProj = async (
117
117
 
118
118
  await injectCIONotificationPodfileCode(iosPath, useFrameworks);
119
119
 
120
+ // Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
121
+ // If true then skip creating a new group to avoid duplicate folders
122
+ if (xcodeProject.pbxTargetByName(CIO_NOTIFICATION_TARGET_NAME)) {
123
+ console.warn(
124
+ `${CIO_NOTIFICATION_TARGET_NAME} already exists in project. Skipping...`
125
+ );
126
+ return;
127
+ }
128
+
120
129
  const nsePath = `${iosPath}/${CIO_NOTIFICATION_TARGET_NAME}`;
121
130
  FileManagement.mkdir(nsePath, {
122
131
  recursive: true,
@@ -160,7 +169,7 @@ const addRichPushXcodeProj = async (
160
169
  // files / folder appear in the file explorer in Xcode.
161
170
  const groups = xcodeProject.hash.project.objects['PBXGroup'];
162
171
  Object.keys(groups).forEach((key) => {
163
- if (groups[key].name === undefined) {
172
+ if (groups[key].name === undefined && groups[key].path === undefined) {
164
173
  xcodeProject.addToPbxGroup(extGroup.uuid, key);
165
174
  }
166
175
  });
@@ -290,13 +299,23 @@ const updateNseEnv = (
290
299
  }
291
300
 
292
301
  if (options.pushNotification?.env?.region) {
293
- let region = '';
294
- if (options.pushNotification?.env?.region === 'us') {
295
- region = 'Region.US';
296
- } else if (options.pushNotification?.env?.region === 'eu') {
297
- region = 'Region.EU';
302
+ const regionMap = {
303
+ us: 'Region.US',
304
+ eu: 'Region.EU',
305
+ };
306
+ const region = options.pushNotification?.env?.region?.toLowerCase();
307
+ const mappedRegion = (regionMap as any)[region] || '';
308
+ if (!mappedRegion) {
309
+ console.warn(
310
+ `${options.pushNotification?.env?.region} is an invalid region. Please use the values from the docs: https://customer.io/docs/sdk/expo/getting-started/#configure-the-plugin`
311
+ );
312
+ } else {
313
+ envFileContent = replaceCodeByRegex(
314
+ envFileContent,
315
+ REGION_RE,
316
+ mappedRegion
317
+ );
298
318
  }
299
- envFileContent = replaceCodeByRegex(envFileContent, REGION_RE, region);
300
319
  }
301
320
 
302
321
  FileManagement.writeFile(envFileName, envFileContent);
@@ -311,6 +330,8 @@ async function addPushNotificationFile(
311
330
  const appPath = `${iosPath}/${appName}`;
312
331
  const getTargetFile = (filename: string) => `${appPath}/${filename}`;
313
332
 
333
+ // Check whether {file} exists in the project. If false, then add the file
334
+ // If {file} exists then skip and return
314
335
  if (!FileManagement.exists(getTargetFile(file))) {
315
336
  FileManagement.mkdir(appPath, {
316
337
  recursive: true,
@@ -323,6 +344,7 @@ async function addPushNotificationFile(
323
344
  );
324
345
  } else {
325
346
  console.log(`${getTargetFile(file)} already exists. Skipping...`);
347
+ return;
326
348
  }
327
349
 
328
350
  const group = xcodeProject.pbxCreateGroup('CustomerIONotifications');