customerio-expo-plugin 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/package.json +7 -1
  2. package/plugin/lib/commonjs/helpers/constants/ios.js +76 -8
  3. package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -1
  4. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +20 -7
  5. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  6. package/plugin/lib/commonjs/index.js +7 -0
  7. package/plugin/lib/commonjs/index.js.map +1 -1
  8. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +18 -12
  9. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  10. package/plugin/lib/commonjs/postInstallHelper.js +58 -11
  11. package/plugin/lib/commonjs/postInstallHelper.js.map +1 -1
  12. package/plugin/lib/commonjs/utils/resolveRNSDK.js +97 -0
  13. package/plugin/lib/commonjs/utils/resolveRNSDK.js.map +1 -0
  14. package/plugin/lib/commonjs/utils/writeExpoVersion.js +56 -0
  15. package/plugin/lib/commonjs/utils/writeExpoVersion.js.map +1 -0
  16. package/plugin/lib/module/helpers/constants/ios.js +75 -8
  17. package/plugin/lib/module/helpers/constants/ios.js.map +1 -1
  18. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +20 -7
  19. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  20. package/plugin/lib/module/index.js +7 -0
  21. package/plugin/lib/module/index.js.map +1 -1
  22. package/plugin/lib/module/ios/withCIOIosSwift.js +18 -12
  23. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  24. package/plugin/lib/module/postInstallHelper.js +58 -11
  25. package/plugin/lib/module/postInstallHelper.js.map +1 -1
  26. package/plugin/lib/module/utils/resolveRNSDK.js +88 -0
  27. package/plugin/lib/module/utils/resolveRNSDK.js.map +1 -0
  28. package/plugin/lib/module/utils/writeExpoVersion.js +48 -0
  29. package/plugin/lib/module/utils/writeExpoVersion.js.map +1 -0
  30. package/plugin/lib/typescript/helpers/constants/ios.d.ts +18 -0
  31. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +11 -1
  32. package/plugin/lib/typescript/utils/resolveRNSDK.d.ts +7 -0
  33. package/plugin/lib/typescript/utils/writeExpoVersion.d.ts +3 -0
  34. package/plugin/src/helpers/constants/ios.ts +87 -8
  35. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +22 -10
  36. package/plugin/src/index.ts +7 -0
  37. package/plugin/src/ios/withCIOIosSwift.ts +25 -12
  38. package/plugin/src/postInstallHelper.js +75 -17
  39. package/plugin/src/utils/resolveRNSDK.ts +118 -0
  40. package/plugin/src/utils/writeExpoVersion.ts +62 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Expo config plugin for the Customer IO React Native SDK",
5
5
  "main": "plugin/lib/commonjs/index",
6
6
  "module": "plugin/lib/module/index",
@@ -34,10 +34,16 @@
34
34
  "compatibility:validate-plugin": "node scripts/compatibility/validate-plugin.js",
35
35
  "compatibility:run-compatibility-tests": "node scripts/compatibility/run-compatibility-tests.js",
36
36
  "setup-test-app": "bash scripts/setup-test-app.sh",
37
+ "setup-test-app-pnpm": "bash scripts/setup-test-app-pnpm.sh",
38
+ "setup-test-app-pnpm-monorepo": "bash scripts/setup-test-app-pnpm-monorepo.sh",
37
39
  "test-plugin": "bash scripts/test-plugin.sh",
38
40
  "cleanAll": "bash scripts/clean-all.sh",
39
41
  "buildAll": "bash scripts/build-all.sh",
40
42
  "cleanAndBuildAll": "npm run cleanAll && npm run buildAll",
43
+ "cleanAllPnpm": "bash scripts/clean-all-pnpm.sh",
44
+ "buildAllPnpm": "bash scripts/build-all-pnpm.sh",
45
+ "cleanAndBuildAllPnpm": "npm run cleanAllPnpm && npm run buildAllPnpm",
46
+ "verify-pnpm-dev-apps": "bash scripts/verify-pnpm-dev-apps.sh",
41
47
  "generate-api-docs": "bash scripts/generate-api-docs.sh"
42
48
  },
43
49
  "keywords": [
@@ -5,17 +5,85 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.IOS_DEPLOYMENT_TARGET = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.DEFAULT_BUNDLE_VERSION = exports.DEFAULT_BUNDLE_SHORT_VERSION = exports.CIO_TARGET_NAME = exports.CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = exports.CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = exports.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = exports.CIO_NOTIFICATION_TARGET_NAME = exports.CIO_NATIVE_SDK_INITIALIZE_SNIPPET = exports.CIO_NATIVE_SDK_INITIALIZE_CALL = exports.CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = exports.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = exports.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX = exports.CIO_INITIALIZECIOSDK_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = exports.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX = exports.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX = exports.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX = exports.CIO_DEEPLINK_COMMENT_REGEX = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = exports.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = exports.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = exports.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET = exports.CIO_APPDELEGATEHEADER_REGEX = exports.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = exports.CIO_APPDELEGATEDECLARATION_REGEX = exports.BUNDLE_VERSION_TEMPLATE_REGEX = exports.BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = void 0;
7
7
  exports.getRelativePathToRNSDK = getRelativePathToRNSDK;
8
+ var _fs = _interopRequireDefault(require("fs"));
9
+ var semver = _interopRequireWildcard(require("semver"));
10
+ var _resolveRNSDK = require("../../utils/resolveRNSDK");
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
13
  const path = require('path');
9
- const resolveFrom = require('resolve-from');
10
- function getRelativePathToRNSDK(iosPath) {
11
- // Root path of the Expo project
12
- const rootAppPath = path.dirname(iosPath);
14
+ // Threshold at which React Native pod autolinking moves from
15
+ // @react-native-community/cli (lexical, symlink-preserving) to
16
+ // expo-modules-autolinking (realpath). The two flavors emit different
17
+ // :path strings on pnpm/yarn-symlink layouts, so to keep CocoaPods happy
18
+ // we must match whichever flavor will resolve the same package later.
19
+ const RN_REALPATH_AUTOLINKING_MIN_VERSION = '0.80.0';
20
+ const PLUGIN_LOG_PREFIX = '[CustomerIO Plugin]';
13
21
 
14
- // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json
15
- const pluginPackageJsonPath = resolveFrom.silent(rootAppPath, `customerio-reactnative/package.json`);
22
+ // Always-on so the trail shows up in customer-shared `expo prebuild`
23
+ // output without needing a separate verbose-mode opt-in.
24
+ function pluginLog(message) {
25
+ // eslint-disable-next-line no-console
26
+ console.log(`${PLUGIN_LOG_PREFIX} ${message}`);
27
+ }
16
28
 
17
- // Example: ../node_modules/customerio-reactnative
18
- return path.relative(iosPath, path.dirname(pluginPackageJsonPath));
29
+ /**
30
+ * Returns the relative path from the iOS project dir to the installed
31
+ * customerio-reactnative directory, in the exact form React Native pod
32
+ * autolinking will emit for the same package. The two autolinking
33
+ * flavors disagree on path shape under pnpm/yarn symlinks:
34
+ *
35
+ * - RN <0.80 (`@react-native-community/cli`): walks node_modules
36
+ * lexically, preserves symlinks. We keep the symlink path too —
37
+ * `tryResolveRNSDK` already does this without calling realpath.
38
+ *
39
+ * - RN >=0.80 (`expo-modules-autolinking`): realpaths the package
40
+ * via Node, emitting the underlying `.pnpm/...` (or yarn-classic)
41
+ * path. We match by realpath'ing the resolved directory.
42
+ *
43
+ * Decision points are logged so a customer's prebuild output is enough
44
+ * to triage path-resolution issues without a follow-up "set
45
+ * CUSTOMERIO_DEBUG_MODE and rerun" round-trip.
46
+ */
47
+ function getRelativePathToRNSDK(iosPath) {
48
+ const rootAppPath = path.dirname(iosPath);
49
+ pluginLog(`Resolving customerio-reactnative for Podfile (iosPath=${iosPath}, projectRoot=${rootAppPath})`);
50
+ const {
51
+ packageDir
52
+ } = (0, _resolveRNSDK.resolveRNSDK)(rootAppPath);
53
+ pluginLog(`customerio-reactnative resolved to: ${packageDir}`);
54
+ const rnVersion = (0, _resolveRNSDK.tryReadRNVersion)(rootAppPath);
55
+ pluginLog(`Detected react-native version: ${rnVersion ?? 'unknown'}`);
56
+ const useLexical = shouldUseLexicalPath(rnVersion);
57
+ pluginLog(useLexical ? `RN <${RN_REALPATH_AUTOLINKING_MIN_VERSION} — using lexical/symlink path to match @react-native-community/cli autolinking` : `RN >=${RN_REALPATH_AUTOLINKING_MIN_VERSION} or unknown — using realpath to match expo-modules-autolinking`);
58
+ let absolutePath;
59
+ if (useLexical) {
60
+ absolutePath = packageDir;
61
+ } else {
62
+ try {
63
+ absolutePath = _fs.default.realpathSync(packageDir);
64
+ if (absolutePath !== packageDir) {
65
+ pluginLog(`Realpath differs from resolved dir: ${absolutePath}`);
66
+ }
67
+ } catch (err) {
68
+ pluginLog(`realpathSync failed (${err instanceof Error ? err.message : String(err)}); falling back to symlink path`);
69
+ absolutePath = packageDir;
70
+ }
71
+ }
72
+ const relativePath = path.relative(iosPath, absolutePath);
73
+ pluginLog(`Final Podfile :path => '${relativePath}'`);
74
+ return relativePath;
75
+ }
76
+ function shouldUseLexicalPath(rnVersion) {
77
+ if (!rnVersion) {
78
+ // Modern Expo (realpath) has been the working path for the last few
79
+ // SDKs, so it's the safer default when RN can't be detected.
80
+ return false;
81
+ }
82
+ const coerced = semver.valid(rnVersion) || semver.coerce(rnVersion);
83
+ if (!coerced) {
84
+ return false;
85
+ }
86
+ return semver.lt(coerced, RN_REALPATH_AUTOLINKING_MIN_VERSION);
19
87
  }
20
88
  const IOS_DEPLOYMENT_TARGET = exports.IOS_DEPLOYMENT_TARGET = '13.0';
21
89
  const GROUP_IDENTIFIER_TEMPLATE_REGEX = exports.GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
@@ -1 +1 @@
1
- {"version":3,"names":["path","require","resolveFrom","getRelativePathToRNSDK","iosPath","rootAppPath","dirname","pluginPackageJsonPath","silent","relative","IOS_DEPLOYMENT_TARGET","exports","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","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["const path = require('path');\nconst resolveFrom = require('resolve-from');\n\nexport function getRelativePathToRNSDK(iosPath: string) {\n // Root path of the Expo project\n const rootAppPath = path.dirname(iosPath);\n\n // Path of the cio RN package.json file. Example: test-app/node_modules/customerio-reactnative/package.json\n const pluginPackageJsonPath = resolveFrom.silent(\n rootAppPath,\n `customerio-reactnative/package.json`\n );\n\n // Example: ../node_modules/customerio-reactnative\n return path.relative(iosPath, path.dirname(pluginPackageJsonPath));\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\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 /.*\\[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\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\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';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n// Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)\nexport const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\\.initialize)/;\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE_CALL}\n `;\n"],"mappings":";;;;;;;AAAA,MAAMA,IAAI,GAAGC,OAAO,CAAC,MAAM,CAAC;AAC5B,MAAMC,WAAW,GAAGD,OAAO,CAAC,cAAc,CAAC;AAEpC,SAASE,sBAAsBA,CAACC,OAAe,EAAE;EACtD;EACA,MAAMC,WAAW,GAAGL,IAAI,CAACM,OAAO,CAACF,OAAO,CAAC;;EAEzC;EACA,MAAMG,qBAAqB,GAAGL,WAAW,CAACM,MAAM,CAC9CH,WAAW,EACX,qCACF,CAAC;;EAED;EACA,OAAOL,IAAI,CAACS,QAAQ,CAACL,OAAO,EAAEJ,IAAI,CAACM,OAAO,CAACC,qBAAqB,CAAC,CAAC;AACpE;AAEO,MAAMG,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,GAAG,MAAM;AACpC,MAAME,+BAA+B,GAAAD,OAAA,CAAAC,+BAAA,GAAG,wBAAwB;AAChE,MAAMC,mCAAmC,GAAAF,OAAA,CAAAE,mCAAA,GAAG,4BAA4B;AACxE,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GAAG,sBAAsB;AAC5D,MAAMC,kCAAkC,GAAAJ,OAAA,CAAAI,kCAAA,GAC7C,wFAAwF;AAEnF,MAAMC,0DAA0D,GAAAL,OAAA,CAAAK,0DAAA,GACrE,kGAAkG;AAE7F,MAAMC,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C,GAAAxB,OAAA,CAAAwB,2CAAA,GAAG;AAC3D;AACA;AACA,CAAC;AAEM,MAAMC,4BAA4B,GAAAzB,OAAA,CAAAyB,4BAAA,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,yCAAyC,GAAA1B,OAAA,CAAA0B,yCAAA,GAAG;AACzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,+CAA+C,GAAA3B,OAAA,CAAA2B,+CAAA,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qCAAqC,GAAA5B,OAAA,CAAA4B,qCAAA,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEG,MAAMC,wCAAwC,GAAA7B,OAAA,CAAA6B,wCAAA,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEC,MAAMC,0CAA0C,GAAA9B,OAAA,CAAA8B,0CAAA,GAAG,0BAA0B;AACpF;AACO,MAAMC,0CAA0C,GAAA/B,OAAA,CAAA+B,0CAAA,GAAG,wCAAwC;AAC3F,MAAMC,8BAA8B,GAAAhC,OAAA,CAAAgC,8BAAA,GAAG,uCAAuC;AAC9E,MAAMC,iCAAiC,GAAAjC,OAAA,CAAAiC,iCAAA,GAAG;AACjD,MAAMD,8BAA8B;AACpC,KAAK","ignoreList":[]}
1
+ {"version":3,"names":["_fs","_interopRequireDefault","require","semver","_interopRequireWildcard","_resolveRNSDK","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","path","RN_REALPATH_AUTOLINKING_MIN_VERSION","PLUGIN_LOG_PREFIX","pluginLog","message","console","log","getRelativePathToRNSDK","iosPath","rootAppPath","dirname","packageDir","resolveRNSDK","rnVersion","tryReadRNVersion","useLexical","shouldUseLexicalPath","absolutePath","fs","realpathSync","err","Error","String","relativePath","relative","coerced","valid","coerce","lt","IOS_DEPLOYMENT_TARGET","exports","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","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_DEEPLINK_COMMENT_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_INITIALIZECIOSDK_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["import fs from 'fs';\nimport * as semver from 'semver';\n\nconst path = require('path');\nimport { resolveRNSDK, tryReadRNVersion } from '../../utils/resolveRNSDK';\n\n// Threshold at which React Native pod autolinking moves from\n// @react-native-community/cli (lexical, symlink-preserving) to\n// expo-modules-autolinking (realpath). The two flavors emit different\n// :path strings on pnpm/yarn-symlink layouts, so to keep CocoaPods happy\n// we must match whichever flavor will resolve the same package later.\nconst RN_REALPATH_AUTOLINKING_MIN_VERSION = '0.80.0';\n\nconst PLUGIN_LOG_PREFIX = '[CustomerIO Plugin]';\n\n// Always-on so the trail shows up in customer-shared `expo prebuild`\n// output without needing a separate verbose-mode opt-in.\nfunction pluginLog(message: string): void {\n // eslint-disable-next-line no-console\n console.log(`${PLUGIN_LOG_PREFIX} ${message}`);\n}\n\n/**\n * Returns the relative path from the iOS project dir to the installed\n * customerio-reactnative directory, in the exact form React Native pod\n * autolinking will emit for the same package. The two autolinking\n * flavors disagree on path shape under pnpm/yarn symlinks:\n *\n * - RN <0.80 (`@react-native-community/cli`): walks node_modules\n * lexically, preserves symlinks. We keep the symlink path too —\n * `tryResolveRNSDK` already does this without calling realpath.\n *\n * - RN >=0.80 (`expo-modules-autolinking`): realpaths the package\n * via Node, emitting the underlying `.pnpm/...` (or yarn-classic)\n * path. We match by realpath'ing the resolved directory.\n *\n * Decision points are logged so a customer's prebuild output is enough\n * to triage path-resolution issues without a follow-up \"set\n * CUSTOMERIO_DEBUG_MODE and rerun\" round-trip.\n */\nexport function getRelativePathToRNSDK(iosPath: string) {\n const rootAppPath = path.dirname(iosPath);\n pluginLog(\n `Resolving customerio-reactnative for Podfile (iosPath=${iosPath}, projectRoot=${rootAppPath})`\n );\n\n const { packageDir } = resolveRNSDK(rootAppPath);\n pluginLog(`customerio-reactnative resolved to: ${packageDir}`);\n\n const rnVersion = tryReadRNVersion(rootAppPath);\n pluginLog(`Detected react-native version: ${rnVersion ?? 'unknown'}`);\n\n const useLexical = shouldUseLexicalPath(rnVersion);\n pluginLog(\n useLexical\n ? `RN <${RN_REALPATH_AUTOLINKING_MIN_VERSION} — using lexical/symlink path to match @react-native-community/cli autolinking`\n : `RN >=${RN_REALPATH_AUTOLINKING_MIN_VERSION} or unknown — using realpath to match expo-modules-autolinking`\n );\n\n let absolutePath: string;\n if (useLexical) {\n absolutePath = packageDir;\n } else {\n try {\n absolutePath = fs.realpathSync(packageDir);\n if (absolutePath !== packageDir) {\n pluginLog(`Realpath differs from resolved dir: ${absolutePath}`);\n }\n } catch (err) {\n pluginLog(\n `realpathSync failed (${\n err instanceof Error ? err.message : String(err)\n }); falling back to symlink path`\n );\n absolutePath = packageDir;\n }\n }\n\n const relativePath = path.relative(iosPath, absolutePath);\n pluginLog(`Final Podfile :path => '${relativePath}'`);\n return relativePath;\n}\n\nfunction shouldUseLexicalPath(rnVersion: string | null): boolean {\n if (!rnVersion) {\n // Modern Expo (realpath) has been the working path for the last few\n // SDKs, so it's the safer default when RN can't be detected.\n return false;\n }\n const coerced = semver.valid(rnVersion) || semver.coerce(rnVersion);\n if (!coerced) {\n return false;\n }\n return semver.lt(coerced, RN_REALPATH_AUTOLINKING_MIN_VERSION);\n}\n\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\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 /.*\\[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\\s*:\\s*EXAppDelegateWrapper\\s*)(<([^>]+)>)?/;\n\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*RCTBridge\\s*\\*\\s*\\w+\\s*=\\s*\\[\\s*self\\.reactDelegate\\s+createBridgeWithDelegate:self\\s+launchOptions:launchOptions\\s*\\];\\s*$/gm;\n\nexport const CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX =\n /^\\s*return\\s\\[\\s*super\\s*application:\\s*application\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\];/gm;\n\nexport const CIO_DEEPLINK_COMMENT_REGEX =\n /\\sDeep link workaround for app killed state start/gm;\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';\n\nexport const CIO_APPDELEGATEHEADER_IMPORT_SNIPPET = `#import <UserNotifications/UserNotifications.h>`;\nexport const CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET =\n 'UNUserNotificationCenterDelegate';\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\nexport const CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET = `\nRCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:modifiedLaunchOptions];\n`;\n\nexport const CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET = `\nreturn [super application:application didFinishLaunchingWithOptions:modifiedLaunchOptions];`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [super application:application didFailToRegisterForRemoteNotificationsWithError:error];\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification];\n`;\n\nexport const CIO_INITIALIZECIOSDK_SNIPPET = ` \n [pnHandlerObj initializeCioSdk];\n\n// Code to make the CIO SDK compatible with expo-notifications package.\n// \n// The CIO SDK and expo-notifications both need to handle when a push gets clicked. However, iOS only allows one click handler to be set per app.\n// To get around this limitation, we set the CIO SDK as the click handler. The CIO SDK sets itself up so that when another SDK or host iOS app \n// sets itself as the click handler, the CIO SDK will still be able to handle when the push gets clicked, even though it's not the designated \n// click handler in iOS at runtime. \n// \n// This should work for most SDKs. However, expo-notifications is unique in it's implementation. It will not setup push click handling it if detects \n// that another SDK or host iOS app has already set itself as the click handler:\n// https://github.com/expo/expo/blob/1b29637bec0b9888e8bc8c310476293a3e2d9786/packages/expo-notifications/ios/EXNotifications/Notifications/EXNotificationCenterDelegate.m#L31-L37\n// ...to get around this, we must manually set it as the click handler after the CIO SDK. That's what this code block does.\n//\n// Note: Initialize the native iOS SDK and setup SDK push click handling before running this code. \n# if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n // Creating a new instance, as the comments in expo-notifications suggests, does not work. With this code, if you send a CIO push to device and click on it,\n // no push metrics reporting will occur.\n // EXNotificationCenterDelegate *notificationCenterDelegate = [[EXNotificationCenterDelegate alloc] init];\n\n // ...instead, get the singleton reference from Expo. \n id<UNUserNotificationCenterDelegate> notificationCenterDelegate = (id<UNUserNotificationCenterDelegate>) [EXModuleRegistryProvider getSingletonModuleForClass:[EXNotificationCenterDelegate class]];\n UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];\n center.delegate = notificationCenterDelegate;\n# endif\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET = `\n// Deep link workaround for app killed state start\nNSMutableDictionary *modifiedLaunchOptions = [NSMutableDictionary dictionaryWithDictionary:launchOptions];\n if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) {\n NSDictionary *pushContent = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];\n if (pushContent[@\"CIO\"] && pushContent[@\"CIO\"][@\"push\"] && pushContent[@\"CIO\"][@\"push\"][@\"link\"]) {\n NSString *initialURL = pushContent[@\"CIO\"][@\"push\"][@\"link\"];\n if (!launchOptions[UIApplicationLaunchOptionsURLKey]) {\n modifiedLaunchOptions[UIApplicationLaunchOptionsURLKey] = [NSURL URLWithString:initialURL];\n }\n }\n }\n//Deep link workaround for app killed state ends\n`;\n\nexport const CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET = `\n // Deep link workaround for app killed state start\n var modifiedLaunchOptions = launchOptions\n if let launchOptions = launchOptions,\n let pushContent = launchOptions[UIApplication.LaunchOptionsKey.remoteNotification] as? [AnyHashable: Any],\n let cio = pushContent[\"CIO\"] as? [String: Any],\n let push = cio[\"push\"] as? [String: Any],\n let link = push[\"link\"] as? String,\n !launchOptions.keys.contains(UIApplication.LaunchOptionsKey.url) {\n \n var mutableLaunchOptions = launchOptions\n mutableLaunchOptions[UIApplication.LaunchOptionsKey.url] = URL(string: link)\n modifiedLaunchOptions = mutableLaunchOptions\n }\n // Deep link workaround for app killed state ends\n`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET = `\n@objc(registerPushNotification)\n public func registerPushNotification() {\n\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2 = `\n let center = UNUserNotificationCenter.current()\n center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in\n if error == nil{\n DispatchQueue.main.async {\n UIApplication.shared.registerForRemoteNotifications()\n }\n }\n }`;\n\nexport const CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER = /\\{\\{REGISTER_SNIPPET\\}\\}/;\n// Regex to match MessagingPush initialization in AppDelegate (different from NSE initialization)\nexport const CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX = /(MessagingPush(?:APN|FCM)\\.initialize)/;\nexport const CIO_NATIVE_SDK_INITIALIZE_CALL = 'CustomerIOSDKInitializer.initialize()';\nexport const CIO_NATIVE_SDK_INITIALIZE_SNIPPET = `// Auto Initialize Native Customer.io SDK\n ${CIO_NATIVE_SDK_INITIALIZE_CALL}\n `;\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAGA,IAAAG,aAAA,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AAC;AAEM,MAAMC,+CAA+C,GAAA3B,OAAA,CAAA2B,+CAAA,GAAG;AAC/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAEM,MAAMC,qCAAqC,GAAA5B,OAAA,CAAA4B,qCAAA,GAAG;AACrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AAEG,MAAMC,wCAAwC,GAAA7B,OAAA,CAAA6B,wCAAA,GAAG;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AAEC,MAAMC,0CAA0C,GAAA9B,OAAA,CAAA8B,0CAAA,GAAG,0BAA0B;AACpF;AACO,MAAMC,0CAA0C,GAAA/B,OAAA,CAAA+B,0CAAA,GAAG,wCAAwC;AAC3F,MAAMC,8BAA8B,GAAAhC,OAAA,CAAAgC,8BAAA,GAAG,uCAAuC;AAC9E,MAAMC,iCAAiC,GAAAjC,OAAA,CAAAiC,iCAAA,GAAG;AACjD,MAAMD,8BAA8B;AACpC,KAAK","ignoreList":[]}
@@ -10,20 +10,30 @@ var _logger = require("../../utils/logger");
10
10
  var _ios = require("../constants/ios");
11
11
  var _codeInjection = require("./codeInjection");
12
12
  var _fileManagement = require("./fileManagement");
13
- /** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
13
+ /** Builds the host-app pod snippet for the Podfile.
14
+ *
15
+ * The :path is resolved at prebuild time by `getRelativePathToRNSDK`,
16
+ * which dispatches on the installed React Native version so the path
17
+ * matches what RN pod autolinking will emit (lexical for RN <0.80,
18
+ * realpath for RN >=0.80). Baking the resolved string directly avoids
19
+ * any Ruby/install-time logic in the Podfile and keeps the snippet
20
+ * trivially diff-able.
21
+ *
22
+ * Exported for tests.
23
+ */
14
24
  function buildHostAppPodSnippet(iosPath, isFcmPushProvider, options) {
15
- const path = (0, _ios.getRelativePathToRNSDK)(iosPath);
25
+ const resolvedPath = (0, _ios.getRelativePathToRNSDK)(iosPath);
16
26
  const locationEnabled = (options === null || options === void 0 ? void 0 : options.locationEnabled) === true;
17
27
  const hasPush = (options === null || options === void 0 ? void 0 : options.hasPush) !== false;
18
28
  if (!locationEnabled) {
19
29
  const subspec = isFcmPushProvider ? 'fcm' : 'apn';
20
- return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;
30
+ return `pod 'customerio-reactnative/${subspec}', :path => '${resolvedPath}'`;
21
31
  }
22
32
  if (!hasPush) {
23
- return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;
33
+ return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${resolvedPath}'`;
24
34
  }
25
35
  const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';
26
- return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;
36
+ return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${resolvedPath}'`;
27
37
  }
28
38
  async function injectCIOPodfileCode(iosPath, isFcmPushProvider, options) {
29
39
  const blockStart = '# --- CustomerIO Host App START ---';
@@ -54,11 +64,14 @@ async function injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmPus
54
64
  const blockEnd = '# --- CustomerIO Notification END ---';
55
65
  const matches = podfile.match(new RegExp(blockStart));
56
66
  if (!matches) {
67
+ const resolvedPath = (0, _ios.getRelativePathToRNSDK)(iosPath);
68
+ const subspec = isFcmPushProvider ? 'fcm' : 'apn';
69
+ const useFrameworksLine = useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : '';
57
70
  const snippetToInjectInPodfile = `
58
71
  ${blockStart}
59
72
  target 'NotificationService' do
60
- ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
61
- pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${(0, _ios.getRelativePathToRNSDK)(iosPath)}'
73
+ ${useFrameworksLine}
74
+ pod 'customerio-reactnative-richpush/${subspec}', :path => '${resolvedPath}'
62
75
  end
63
76
  ${blockEnd}
64
77
  `.trim();
@@ -1 +1 @@
1
- {"version":3,"names":["_logger","require","_ios","_codeInjection","_fileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","path","getRelativePathToRNSDK","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","injectCodeByRegex","join","logger","info","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const path = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;\n }\n\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;\n }\n\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${blockStart}\n ${podLine}\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AASA;AACO,SAASI,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0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IAEJR,8BAAc,CAACS,KAAK,CAClBX,QAAQ,EACR,IAAAY,gCAAiB,EACfX,OAAO,EACPM,kCAAkC,EAClCE,wBACF,CAAC,CAACI,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,cAAM,CAACC,IAAI,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgCA,CACpD5B,OAAe,EACf6B,aAA0D,EAC1D5B,iBAA0B,EAC1B;EACA,MAAMW,QAAQ,GAAG,GAAGZ,OAAO,UAAU;EACrC,MAAMa,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMK,wBAAwB,GAAG;AACrC,EAAEX,UAAU;AACZ;AACA,IAAImB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyC5B,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpD,IAAAG,2BAAsB,EAACJ,OAAO,CAAC;AACrD;AACA,EAAEW,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACgB,MAAM,CAAClB,QAAQ,EAAES,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
1
+ {"version":3,"names":["_logger","require","_ios","_codeInjection","_fileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","resolvedPath","getRelativePathToRNSDK","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","injectCodeByRegex","join","logger","info","injectCIONotificationPodfileCode","useFrameworks","useFrameworksLine","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host-app pod snippet for the Podfile.\n *\n * The :path is resolved at prebuild time by `getRelativePathToRNSDK`,\n * which dispatches on the installed React Native version so the path\n * matches what RN pod autolinking will emit (lexical for RN <0.80,\n * realpath for RN >=0.80). Baking the resolved string directly avoids\n * any Ruby/install-time logic in the Podfile and keeps the snippet\n * trivially diff-able.\n *\n * Exported for tests.\n */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const resolvedPath = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${resolvedPath}'`;\n }\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${resolvedPath}'`;\n }\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${resolvedPath}'`;\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${blockStart}\n ${podLine}\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const resolvedPath = getRelativePathToRNSDK(iosPath);\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n const useFrameworksLine =\n useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : '';\n\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworksLine}\n pod 'customerio-reactnative-richpush/${subspec}', :path => '${resolvedPath}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACz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AK,CAClBX,QAAQ,EACR,IAAAY,gCAAiB,EACfX,OAAO,EACPM,kCAAkC,EAClCE,wBACF,CAAC,CAACI,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,cAAM,CAACC,IAAI,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgCA,CACpD5B,OAAe,EACf6B,aAA0D,EAC1D5B,iBAA0B,EAC1B;EACA,MAAMW,QAAQ,GAAG,GAAGZ,OAAO,UAAU;EACrC,MAAMa,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMb,YAAY,GAAG,IAAAC,2BAAsB,EAACJ,OAAO,CAAC;IACpD,MAAMO,OAAO,GAAGN,iBAAiB,GAAG,KAAK,GAAG,KAAK;IACjD,MAAM6B,iBAAiB,GACrBD,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;IAEzE,MAAMR,wBAAwB,GAAG;AACrC,EAAEX,UAAU;AACZ;AACA,IAAIoB,iBAAiB;AACrB,yCAAyCvB,OAAO,gBAAgBJ,YAAY;AAC5E;AACA,EAAEQ,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACiB,MAAM,CAACnB,QAAQ,EAAES,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _withCIOAndroid = require("./android/withCIOAndroid");
8
8
  var _utils = require("./ios/utils");
9
9
  var _withCIOIos = require("./ios/withCIOIos");
10
+ var _writeExpoVersion = require("./utils/writeExpoVersion");
10
11
  // Entry point for config plugin
11
12
  function withCustomerIOPlugin(config, props) {
12
13
  // Check if config is being used with unsupported Expo version
@@ -14,6 +15,12 @@ function withCustomerIOPlugin(config, props) {
14
15
  throw new Error('CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' + 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' + 'See documentation for manual setup instructions.');
15
16
  }
16
17
 
18
+ // Belt-and-suspenders write of the plugin version into the RN SDK's
19
+ // package.json. The postinstall hook does the same write at install time;
20
+ // this covers installs where postinstall didn't run cleanly (pnpm with
21
+ // strict store layouts, --ignore-scripts, cached CI installs, etc).
22
+ config = (0, _writeExpoVersion.withExpoVersion)(config);
23
+
17
24
  // Apply platform specific modifications
18
25
  config = (0, _withCIOIos.withCIOIos)(config, props.config, props.ios, props.location);
19
26
  config = (0, _withCIOAndroid.withCIOAndroid)(config, props.config, props.android, props.location);
@@ -1 +1 @@
1
- {"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","withCustomerIOPlugin","config","props","isExpoVersion53OrHigher","Error","withCIOIos","ios","location","withCIOAndroid","android","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA;AACA,SAASG,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAAC,IAAAE,8BAAuB,EAACF,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIG,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAH,MAAM,GAAG,IAAAI,sBAAU,EAACJ,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,GAAG,EAAEJ,KAAK,CAACK,QAAQ,CAAC;EACpEN,MAAM,GAAG,IAAAO,8BAAc,EAACP,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACO,OAAO,EAAEP,KAAK,CAACK,QAAQ,CAAC;EAE5E,OAAON,MAAM;AACf;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcZ,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","_writeExpoVersion","withCustomerIOPlugin","config","props","isExpoVersion53OrHigher","Error","withExpoVersion","withCIOIos","ios","location","withCIOAndroid","android","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\nimport { withExpoVersion } from './utils/writeExpoVersion';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Belt-and-suspenders write of the plugin version into the RN SDK's\n // package.json. The postinstall hook does the same write at install time;\n // this covers installs where postinstall didn't run cleanly (pnpm with\n // strict store layouts, --ignore-scripts, cached CI installs, etc).\n config = withExpoVersion(config);\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,iBAAA,GAAAH,OAAA;AAIA;AACA,SAASI,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAAC,IAAAE,8BAAuB,EAACF,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIG,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACA;EACA;EACA;EACAH,MAAM,GAAG,IAAAI,iCAAe,EAACJ,MAAM,CAAC;;EAEhC;EACAA,MAAM,GAAG,IAAAK,sBAAU,EAACL,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACK,GAAG,EAAEL,KAAK,CAACM,QAAQ,CAAC;EACpEP,MAAM,GAAG,IAAAQ,8BAAc,EAACR,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACQ,OAAO,EAAER,KAAK,CAACM,QAAQ,CAAC;EAE5E,OAAOP,MAAM;AACf;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcb,oBAAoB","ignoreList":[]}
@@ -339,29 +339,35 @@ const addDidFailToRegisterForRemoteNotificationsWithError = content => {
339
339
 
340
340
  /**
341
341
  * Add deep link handling for killed state
342
- * This replaces the return statement with deep link handling code
343
- * and a modified return statement that uses modifiedLaunchOptions
342
+ *
343
+ * On modern Expo Swift templates, RN is bootstrapped by `factory.startReactNative(...)`
344
+ * inside an `#if os(iOS) || os(tvOS)` guard, *before* the trailing `return super.application(...)`.
345
+ * The deep-link block must run before that call so `modifiedLaunchOptions` flows into RN's
346
+ * initial launchOptions; otherwise the workaround is a no-op.
347
+ *
348
+ * For older templates (no `factory.startReactNative` — `super.application(...)` is what
349
+ * starts RN), the snippet is injected before the return statement as before.
344
350
  */
345
351
  const addHandleDeeplinkInKilledState = content => {
346
- // Check if deep link code snippet is already present
347
352
  const deepLinkMarker = 'Deep link workaround for app killed state start';
348
353
  if (content.includes(deepLinkMarker)) {
349
354
  return content;
350
355
  }
351
-
352
- // Find the return statement with launchOptions
353
356
  const returnStatementRegex = /return\s+super\.application\s*\(\s*application\s*,\s*didFinishLaunchingWithOptions\s*:\s*launchOptions\s*\)/;
354
- const returnStatementMatch = content.match(returnStatementRegex);
355
- if (!returnStatementMatch) {
357
+ const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
358
+ const factoryStartRegex = /(\s*)#if\s+os\(iOS\)\s*\|\|\s*os\(tvOS\)([\s\S]*?factory\.startReactNative\s*\([\s\S]*?launchOptions:\s*)launchOptions(\s*\)[\s\S]*?#endif)/;
359
+ if (factoryStartRegex.test(content)) {
360
+ let result = content.replace(factoryStartRegex, `\n${_ios.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET}\n#if os(iOS) || os(tvOS)$2modifiedLaunchOptions$3`);
361
+ if (returnStatementRegex.test(result)) {
362
+ result = result.replace(returnStatementRegex, modifiedReturnStatement);
363
+ }
364
+ return result;
365
+ }
366
+ if (!returnStatementRegex.test(content)) {
356
367
  _logger.logger.warn('Could not find return statement with launchOptions');
357
368
  return content;
358
369
  }
359
-
360
- // Create the replacement code with deep link handling and modified return statement
361
- const modifiedReturnStatement = 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';
362
370
  const replacementCode = _ios.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET + '\n\n ' + modifiedReturnStatement;
363
-
364
- // Replace the return statement with deep link handling code and modified return statement
365
371
  return content.replace(returnStatementRegex, replacementCode);
366
372
  };
367
373
  //# sourceMappingURL=withCIOIosSwift.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_common","_ios","_codeInjection","_fileManagement","_patchPluginNativeCode","_logger","_plugin","_xcode","_utils","e","__esModule","default","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","logger","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","path","join","group","getOrCreateCustomerIOGroup","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","_props$pushNotificati5","useFcm","isFcmPushProvider","handlerSourcePath","getIosNativeFilesPath","handlerDestPath","FileManagement","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","replaceCodeByRegex","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupId","appGroupIdBuilderLine","JSON","stringify","replace","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","copyFileToXcode","sourceFilePath","targetFileName","transform","content","patchNativeSDKInitializer","PLATFORM","IOS","customerIOGroup","withCIOIosSwift","configOuter","withXcodeProject","withAppDelegate","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","exports","_props$pushNotificati6","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","CIO_NATIVE_SDK_INITIALIZE_CALL","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","replacementCode","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n const appGroupId = props.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig, location });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const locationOptions = location\n ? { enabled: location.enabled === true, trackingMode: sdkConfig?.location?.trackingMode }\n : undefined;\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) =>\n patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n * This replaces the return statement with deep link handling code\n * and a modified return statement that uses modifiedLaunchOptions\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n // Check if deep link code snippet is already present\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n // Find the return statement with launchOptions\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n\n // Create the replacement code with deep link handling and modified return statement\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n\n // Replace the return statement with deep link handling code and modified return statement\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":";;;;;;AAIA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAQA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AAMA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA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uGAAuG,GACvG,+FAA+F,GAC/F,OAAO,GACP7B,OAAO,CAACgC,SAAS,CAACH,QAAQ,CAAC;EAE/B;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMN,8BAA8B,GAAIvB,OAAe,IAAa;EAClE;EACA,MAAM4C,cAAc,GAAG,iDAAiD;EACxE,IAAI5C,OAAO,CAACe,QAAQ,CAAC6B,cAAc,CAAC,EAAE;IACpC,OAAO5C,OAAO;EAChB;;EAEA;EACA,MAAMkC,oBAAoB,GACxB,6GAA6G;EAC/G,MAAMC,oBAAoB,GAAGnC,OAAO,CAAC4B,KAAK,CAACM,oBAAoB,CAAC;EAEhE,IAAI,CAACC,oBAAoB,EAAE;IACzB3F,cAAM,CAACC,IAAI,CAAC,oDAAoD,CAAC;IACjE,OAAOuD,OAAO;EAChB;;EAEA;EACA,MAAM6C,uBAAuB,GAC3B,6FAA6F;EAC/F,MAAMC,eAAe,GACnBC,oDAA+C,GAC/C,UAAU,GACVF,uBAAuB;;EAEzB;EACA,OAAO7C,OAAO,CAACf,OAAO,CAACiD,oBAAoB,EAAEY,eAAe,CAAC;AAC/D,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_configPlugins","require","_path","_interopRequireDefault","_common","_ios","_codeInjection","_fileManagement","_patchPluginNativeCode","_logger","_plugin","_xcode","_utils","e","__esModule","default","CIO_SDK_APP_DELEGATE_HANDLER_CLASS","CIO_SDK_APP_DELEGATE_HANDLER_FILENAME","copyAndConfigureAppDelegateHandler","config","sdkConfig","props","location","projectName","modRequest","logger","warn","xcodeProject","modResults","projectRoot","iosProjectRoot","path","join","group","getOrCreateCustomerIOGroup","pushNotification","copyAndConfigurePushAppDelegateHandler","copyAndConfigureNativeSDKInitializer","_props$pushNotificati","_props$pushNotificati2","_props$pushNotificati3","_props$pushNotificati4","_props$pushNotificati5","useFcm","isFcmPushProvider","handlerSourcePath","getIosNativeFilesPath","handlerDestPath","FileManagement","copyFile","addSourceFile","handlerFileContent","readFile","disableNotificationRegistration","snippet","CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2","replaceCodeByRegex","CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER","autoTrackPushEvents","toString","autoFetchDeviceToken","showPushAppInForeground","appGroupId","appGroupIdBuilderLine","JSON","stringify","replace","CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","writeFile","_sdkConfig$location","locationOptions","enabled","trackingMode","undefined","filename","sourcePath","copyFileToXcode","sourceFilePath","targetFileName","transform","content","patchNativeSDKInitializer","PLATFORM","IOS","customerIOGroup","withCIOIosSwift","configOuter","withXcodeProject","withAppDelegate","modifyAppDelegateWithPushAppDelegateHandler","modifyAppDelegateWithNativeSDKInitializer","exports","_props$pushNotificati6","appDelegateContent","contents","includes","info","modifiedContent","addHandlerPropertyDeclaration","modifyDidFinishLaunchingWithOptions","addDidRegisterForRemoteNotificationsWithDeviceToken","addDidFailToRegisterForRemoteNotificationsWithError","handleDeeplinkInKilledState","addHandleDeeplinkInKilledState","CIO_NATIVE_SDK_INITIALIZE_CALL","methodExistsInAppDelegate","methodSignature","classDeclarationRegex","match","position","index","length","substring","codeToInject","returnStatementRegex","returnStatementMatch","insertPosition","methodRegex","methodContent","openBraceIndex","indexOf","modifiedMethod","classEndRegex","classEndMatch","deepLinkMarker","modifiedReturnStatement","factoryStartRegex","test","result","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET","replacementCode"],"sources":["withCIOIosSwift.ts"],"sourcesContent":["import type {\n ExportedConfigWithProps,\n XcodeProject,\n} from '@expo/config-plugins';\nimport { withAppDelegate, withXcodeProject } from '@expo/config-plugins';\nimport type { ExpoConfig } from '@expo/config-types';\nimport path from 'path';\nimport { PLATFORM } from '../helpers/constants/common';\nimport {\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET,\n CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX,\n CIO_NATIVE_SDK_INITIALIZE_CALL,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n} from '../helpers/constants/ios';\nimport { replaceCodeByRegex } from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { logger } from '../utils/logger';\nimport { getIosNativeFilesPath } from '../utils/plugin';\nimport { copyFileToXcode, getOrCreateCustomerIOGroup } from '../utils/xcode';\nimport { isFcmPushProvider } from './utils';\n\n// Constants\nconst CIO_SDK_APP_DELEGATE_HANDLER_CLASS = 'CioSdkAppDelegateHandler';\nconst CIO_SDK_APP_DELEGATE_HANDLER_FILENAME = `${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}.swift`;\n\n/**\n * Copy and configure the CioSdkAppDelegateHandler.swift file\n */\nconst copyAndConfigureAppDelegateHandler = (\n config: ExportedConfigWithProps<XcodeProject>,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n): ExportedConfigWithProps<XcodeProject> => {\n // Destination path in the iOS project\n const projectName = config.modRequest.projectName || '';\n if (!projectName) {\n logger.warn(\n 'Project name is undefined, cannot copy CustomerIO files'\n );\n return config;\n }\n\n // Add files to the Xcode project\n const xcodeProject = config.modResults;\n const projectRoot = config.modRequest.projectRoot;\n const iosProjectRoot = path.join(projectRoot, 'ios');\n\n const group = getOrCreateCustomerIOGroup(xcodeProject, projectName);\n if (props?.pushNotification) {\n // Copy CioSdkAppDelegateHandler.swift for full push notification + auto-init support\n copyAndConfigurePushAppDelegateHandler({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n });\n } else if (sdkConfig) {\n // Copy only CustomerIOSDKInitializer.swift for auto-init without push notifications\n copyAndConfigureNativeSDKInitializer({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n });\n }\n\n return config;\n};\n\nconst copyAndConfigurePushAppDelegateHandler = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n props,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig | undefined;\n props: CustomerIOPluginOptionsIOS;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const useFcm = isFcmPushProvider(props);\n\n // Source path for the handler file\n const handlerSourcePath = path.join(\n getIosNativeFilesPath(),\n useFcm ? 'fcm' : 'apn',\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n const handlerDestPath = path.join(\n iosProjectRoot,\n projectName,\n CIO_SDK_APP_DELEGATE_HANDLER_FILENAME\n );\n\n FileManagement.copyFile(handlerSourcePath, handlerDestPath);\n\n // Add the file to the Xcode project\n xcodeProject.addSourceFile(\n `${projectName}/${CIO_SDK_APP_DELEGATE_HANDLER_FILENAME}`,\n null,\n group\n );\n\n let handlerFileContent = FileManagement.readFile(handlerDestPath);\n\n const disableNotificationRegistration =\n props.pushNotification?.disableNotificationRegistration;\n let snippet = '';\n // unless this property is explicity set to true, push notification\n // registration will be added to the AppDelegate\n if (disableNotificationRegistration !== true) {\n snippet = CIO_REGISTER_PUSHNOTIFICATION_SNIPPET_v2;\n }\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n CIO_REGISTER_PUSH_NOTIFICATION_PLACEHOLDER,\n snippet\n );\n\n const autoTrackPushEvents =\n props.pushNotification?.autoTrackPushEvents !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_TRACK_PUSH_EVENTS\\}\\}/,\n autoTrackPushEvents.toString()\n );\n\n const autoFetchDeviceToken =\n props.pushNotification?.autoFetchDeviceToken !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{AUTO_FETCH_DEVICE_TOKEN\\}\\}/,\n autoFetchDeviceToken.toString()\n );\n\n const showPushAppInForeground =\n props.pushNotification?.showPushAppInForeground !== false;\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{SHOW_PUSH_APP_IN_FOREGROUND\\}\\}/,\n showPushAppInForeground.toString()\n );\n\n const appGroupId = props.pushNotification?.appGroupId;\n const appGroupIdBuilderLine = appGroupId\n ? ` .appGroupId(${JSON.stringify(appGroupId)})\\n`\n : '';\n handlerFileContent = replaceCodeByRegex(\n handlerFileContent,\n /\\{\\{APP_GROUP_ID_BUILDER_LINE\\}\\}/,\n appGroupIdBuilderLine\n );\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n // Also copy CustomerIOSDKInitializer.swift for auto-initialization\n copyAndConfigureNativeSDKInitializer({ xcodeProject, group, iosProjectRoot, projectName, sdkConfig, location });\n\n // Inject auto initialization call before MessagingPush initialization\n handlerFileContent = handlerFileContent.replace(CIO_MESSAGING_PUSH_APP_DELEGATE_INIT_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET + '$1');\n }\n\n FileManagement.writeFile(handlerDestPath, handlerFileContent);\n};\n\nconst copyAndConfigureNativeSDKInitializer = ({\n xcodeProject,\n group,\n iosProjectRoot,\n projectName,\n sdkConfig,\n location,\n}: {\n xcodeProject: XcodeProject;\n group: XcodeProject['pbxCreateGroup'];\n iosProjectRoot: string;\n projectName: string;\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n}) => {\n const locationOptions = location\n ? { enabled: location.enabled === true, trackingMode: sdkConfig?.location?.trackingMode }\n : undefined;\n const filename = 'CustomerIOSDKInitializer.swift';\n const sourcePath = path.join(getIosNativeFilesPath(), filename);\n // Add the CustomerIOSDKInitializer.swift file to the same Xcode group as CioSdkAppDelegateHandler\n copyFileToXcode({\n xcodeProject,\n iosProjectRoot,\n projectName,\n sourceFilePath: sourcePath,\n targetFileName: filename,\n transform: (content) =>\n patchNativeSDKInitializer(content, PLATFORM.IOS, sdkConfig, locationOptions),\n customerIOGroup: group,\n });\n};\n\nexport const withCIOIosSwift = (\n configOuter: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsIOS,\n location?: CustomerIOPluginLocationOptions,\n) => {\n // First, copy required swift files to iOS folder and add it to Xcode project\n configOuter = withXcodeProject(configOuter, async (config) => {\n return copyAndConfigureAppDelegateHandler(config, sdkConfig, props, location);\n });\n\n // Modify the AppDelegate based on configuration\n if (props?.pushNotification) {\n // With push notifications: delegate to CioSdkAppDelegateHandler for both push and auto-init\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithPushAppDelegateHandler(config, props);\n });\n } else if (sdkConfig) {\n // Without push notifications: directly inject auto initialization into AppDelegate\n return withAppDelegate(configOuter, async (config) => {\n return modifyAppDelegateWithNativeSDKInitializer(config);\n });\n } else {\n return configOuter;\n }\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithPushAppDelegateHandler = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n props: CustomerIOPluginOptionsIOS\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_SDK_APP_DELEGATE_HANDLER_CLASS)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Add the handler property declaration\n let modifiedContent = addHandlerPropertyDeclaration(appDelegateContent);\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n modifiedContent = modifyDidFinishLaunchingWithOptions(\n modifiedContent,\n ` cioSdkHandler.application(application, didFinishLaunchingWithOptions: launchOptions)\\n\\n `\n );\n\n // Add didRegisterForRemoteNotificationsWithDeviceToken implementation\n modifiedContent =\n addDidRegisterForRemoteNotificationsWithDeviceToken(modifiedContent);\n\n // Add didFailToRegisterForRemoteNotificationsWithError implementation\n modifiedContent =\n addDidFailToRegisterForRemoteNotificationsWithError(modifiedContent);\n\n // Add deep link handling for killed state if enabled\n if (props.pushNotification?.handleDeeplinkInKilledState === true) {\n modifiedContent = addHandleDeeplinkInKilledState(modifiedContent);\n }\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Modify the AppDelegate to integrate with Customer.io SDK\n */\nconst modifyAppDelegateWithNativeSDKInitializer = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n config: any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any => {\n const appDelegateContent = config.modResults.contents;\n\n // Check if modifications have already been applied\n if (appDelegateContent.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n logger.info(\n 'CustomerIO Swift AppDelegate changes already exist. Skipping...'\n );\n return config;\n }\n\n // Modify didFinishLaunchingWithOptions to initialize and call the handler\n const modifiedContent = modifyDidFinishLaunchingWithOptions(\n appDelegateContent,\n CIO_NATIVE_SDK_INITIALIZE_SNIPPET,\n );\n\n config.modResults.contents = modifiedContent;\n return config;\n};\n\n/**\n * Check if a method exists in the AppDelegate content\n * @param content The AppDelegate content\n * @param methodSignature The method signature to check for\n * @returns true if the method exists, false otherwise\n */\nconst methodExistsInAppDelegate = (\n content: string,\n methodSignature: string\n): boolean => {\n return content.includes(methodSignature);\n};\n\n/**\n * Add handler property declaration to the AppDelegate class\n * This adds the line: let cioSdkHandler = CioSdkAppDelegateHandler()\n * to the AppDelegate class\n */\nconst addHandlerPropertyDeclaration = (content: string): string => {\n // Look for the AppDelegate class declaration\n const classDeclarationRegex = /class\\s+AppDelegate\\s*:\\s*.*\\s*{/;\n const match = content.match(classDeclarationRegex);\n\n if (!match) {\n logger.warn('Could not find AppDelegate class declaration');\n return content;\n }\n\n const position = (match.index ?? 0) + match[0].length;\n return (\n content.substring(0, position) +\n `\\n let cioSdkHandler = ${CIO_SDK_APP_DELEGATE_HANDLER_CLASS}()\\n` +\n content.substring(position)\n );\n};\n\n/**\n * Modify didFinishLaunchingWithOptions to inject Customer.io code\n * Injects the provided code (either handler call or auto initialization) before the return statement\n */\nconst modifyDidFinishLaunchingWithOptions = (content: string, codeToInject: string): string => {\n // Find the return statement in didFinishLaunchingWithOptions\n // Always look for launchOptions since modifiedLaunchOptions is only set later\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n\n const returnStatementMatch = content.match(returnStatementRegex);\n\n if (!returnStatementMatch) {\n logger.warn(\n 'Could not find return statement with super.application in didFinishLaunchingWithOptions'\n );\n return content;\n }\n\n // Inject Customer.io code before the return statement\n const insertPosition = returnStatementMatch.index ?? 0;\n\n return (\n content.substring(0, insertPosition) +\n codeToInject +\n content.substring(insertPosition)\n );\n};\n\n/**\n * Add or modify didRegisterForRemoteNotificationsWithDeviceToken implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidRegisterForRemoteNotificationsWithDeviceToken = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didRegisterForRemoteNotificationsWithDeviceToken\\s+deviceToken\\s*:\\s*Data\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle device token registration\\n' +\n ' public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add or modify didFailToRegisterForRemoteNotificationsWithError implementation\n * If the method already exists, it adds the handler call to the existing method\n * If the method doesn't exist, it adds a new method implementation\n */\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n content: string\n): string => {\n const methodSignature =\n 'func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error:';\n\n // Check if method already exists\n if (methodExistsInAppDelegate(content, methodSignature)) {\n // Method exists, modify it to call our handler\n const methodRegex =\n /func\\s+application\\s*\\(\\s*_\\s+application\\s*:\\s*UIApplication\\s*,\\s*didFailToRegisterForRemoteNotificationsWithError\\s+error\\s*:\\s*Error\\s*\\)\\s*{[\\s\\S]*?}/;\n const match = content.match(methodRegex);\n\n if (match) {\n // Add our handler call to the existing method\n const methodContent = match[0];\n const openBraceIndex = methodContent.indexOf('{') + 1;\n const modifiedMethod =\n methodContent.substring(0, openBraceIndex) +\n '\\n // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n methodContent.substring(openBraceIndex);\n\n return content.replace(methodRegex, modifiedMethod);\n }\n\n return content;\n } else {\n // Method doesn't exist, add it inside the AppDelegate class\n // Find the end of the AppDelegate class\n const classEndRegex = /^}(\\s*$|\\s*\\/\\/)/m;\n const classEndMatch = content.match(classEndRegex);\n\n if (!classEndMatch) {\n logger.warn('Could not find end of AppDelegate class');\n return content;\n }\n\n // Insert the method inside the class\n const position = classEndMatch.index ?? 0;\n return (\n content.substring(0, position) +\n '\\n // Handle remote notification registration errors\\n' +\n ' public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {\\n' +\n ' // Call CustomerIO SDK handler\\n' +\n ' cioSdkHandler.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' super.application(application, didFailToRegisterForRemoteNotificationsWithError: error)\\n' +\n ' }\\n' +\n content.substring(position)\n );\n }\n};\n\n/**\n * Add deep link handling for killed state\n *\n * On modern Expo Swift templates, RN is bootstrapped by `factory.startReactNative(...)`\n * inside an `#if os(iOS) || os(tvOS)` guard, *before* the trailing `return super.application(...)`.\n * The deep-link block must run before that call so `modifiedLaunchOptions` flows into RN's\n * initial launchOptions; otherwise the workaround is a no-op.\n *\n * For older templates (no `factory.startReactNative` — `super.application(...)` is what\n * starts RN), the snippet is injected before the return statement as before.\n */\nconst addHandleDeeplinkInKilledState = (content: string): string => {\n const deepLinkMarker = 'Deep link workaround for app killed state start';\n if (content.includes(deepLinkMarker)) {\n return content;\n }\n\n const returnStatementRegex =\n /return\\s+super\\.application\\s*\\(\\s*application\\s*,\\s*didFinishLaunchingWithOptions\\s*:\\s*launchOptions\\s*\\)/;\n const modifiedReturnStatement =\n 'return super.application(application, didFinishLaunchingWithOptions: modifiedLaunchOptions)';\n\n const factoryStartRegex =\n /(\\s*)#if\\s+os\\(iOS\\)\\s*\\|\\|\\s*os\\(tvOS\\)([\\s\\S]*?factory\\.startReactNative\\s*\\([\\s\\S]*?launchOptions:\\s*)launchOptions(\\s*\\)[\\s\\S]*?#endif)/;\n\n if (factoryStartRegex.test(content)) {\n let result = content.replace(\n factoryStartRegex,\n `\\n${CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET}\\n#if os(iOS) || os(tvOS)$2modifiedLaunchOptions$3`\n );\n if (returnStatementRegex.test(result)) {\n result = result.replace(returnStatementRegex, modifiedReturnStatement);\n }\n return result;\n }\n\n if (!returnStatementRegex.test(content)) {\n logger.warn('Could not find return statement with launchOptions');\n return content;\n }\n const replacementCode =\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SWIFT_SNIPPET +\n '\\n\\n ' +\n modifiedReturnStatement;\n return content.replace(returnStatementRegex, replacementCode);\n};\n"],"mappings":";;;;;;AAIA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAQA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,sBAAA,GAAAP,OAAA;AAMA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAA4C,SAAAE,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5C;AACA,MAAMG,kCAAkC,GAAG,0BAA0B;AACrE,MAAMC,qCAAqC,GAAG,GAAGD,kCAAkC,QAAQ;;AAE3F;AACA;AACA;AACA,MAAME,kCAAkC,GAAGA,CACzCC,MAA6C,EAC7CC,SAA2B,EAC3BC,KAAkC,EAClCC,QAA0C,KACA;EAC1C;EACA,MAAMC,WAAW,GAAGJ,MAAM,CAACK,UAAU,CAACD,WAAW,IAAI,EAAE;EACv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