customerio-expo-plugin 3.1.0 → 3.3.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 (100) hide show
  1. package/package.json +3 -2
  2. package/plugin/lib/commonjs/android/withCIOAndroid.js +13 -2
  3. package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
  4. package/plugin/lib/commonjs/android/withLocationGradleProperties.js +37 -0
  5. package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -0
  6. package/plugin/lib/commonjs/android/withMainApplicationModifications.js +21 -5
  7. package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
  8. package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
  9. package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
  10. package/plugin/lib/commonjs/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  11. package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  12. package/plugin/lib/commonjs/helpers/native-files/ios/apn/PushService.swift +1 -1
  13. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  14. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  15. package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +1 -1
  16. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +19 -2
  17. package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  18. package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js +50 -0
  19. package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js.map +1 -0
  20. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +3 -1
  21. package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
  22. package/plugin/lib/commonjs/index.js +2 -2
  23. package/plugin/lib/commonjs/index.js.map +1 -1
  24. package/plugin/lib/commonjs/ios/withCIOIos.js +46 -4
  25. package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
  26. package/plugin/lib/commonjs/ios/withCIOIosSwift.js +25 -12
  27. package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
  28. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +45 -11
  29. package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  30. package/plugin/lib/commonjs/ios/withXcodeProject.js +4 -1
  31. package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
  32. package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
  33. package/plugin/lib/commonjs/utils/validation.js +13 -0
  34. package/plugin/lib/commonjs/utils/validation.js.map +1 -1
  35. package/plugin/lib/module/android/withCIOAndroid.js +13 -2
  36. package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
  37. package/plugin/lib/module/android/withLocationGradleProperties.js +30 -0
  38. package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -0
  39. package/plugin/lib/module/android/withMainApplicationModifications.js +20 -4
  40. package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
  41. package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
  42. package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
  43. package/plugin/lib/module/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  44. package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  45. package/plugin/lib/module/helpers/native-files/ios/apn/PushService.swift +1 -1
  46. package/plugin/lib/module/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  47. package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  48. package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +1 -1
  49. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +18 -2
  50. package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  51. package/plugin/lib/module/helpers/utils/patchLocationCode.js +44 -0
  52. package/plugin/lib/module/helpers/utils/patchLocationCode.js.map +1 -0
  53. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +3 -2
  54. package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
  55. package/plugin/lib/module/index.js +2 -2
  56. package/plugin/lib/module/index.js.map +1 -1
  57. package/plugin/lib/module/ios/withCIOIos.js +46 -4
  58. package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
  59. package/plugin/lib/module/ios/withCIOIosSwift.js +25 -12
  60. package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
  61. package/plugin/lib/module/ios/withNotificationsXcodeProject.js +45 -11
  62. package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  63. package/plugin/lib/module/ios/withXcodeProject.js +5 -1
  64. package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
  65. package/plugin/lib/module/types/cio-types.js.map +1 -1
  66. package/plugin/lib/module/utils/validation.js +13 -1
  67. package/plugin/lib/module/utils/validation.js.map +1 -1
  68. package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
  69. package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +9 -0
  70. package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +7 -2
  71. package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +9 -1
  72. package/plugin/lib/typescript/helpers/utils/patchLocationCode.d.ts +12 -0
  73. package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +3 -1
  74. package/plugin/lib/typescript/index.d.ts +2 -1
  75. package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
  76. package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +2 -2
  77. package/plugin/lib/typescript/ios/withXcodeProject.d.ts +8 -1
  78. package/plugin/lib/typescript/types/cio-types.d.ts +35 -0
  79. package/plugin/lib/typescript/utils/validation.d.ts +3 -2
  80. package/plugin/src/android/withCIOAndroid.ts +13 -2
  81. package/plugin/src/android/withLocationGradleProperties.ts +41 -0
  82. package/plugin/src/android/withMainApplicationModifications.ts +26 -4
  83. package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
  84. package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
  85. package/plugin/src/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
  86. package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +1 -1
  87. package/plugin/src/helpers/native-files/ios/apn/PushService.swift +1 -1
  88. package/plugin/src/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
  89. package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
  90. package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +1 -1
  91. package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +35 -3
  92. package/plugin/src/helpers/utils/patchLocationCode.ts +80 -0
  93. package/plugin/src/helpers/utils/patchPluginNativeCode.ts +10 -1
  94. package/plugin/src/index.ts +9 -3
  95. package/plugin/src/ios/withCIOIos.ts +40 -3
  96. package/plugin/src/ios/withCIOIosSwift.ts +30 -4
  97. package/plugin/src/ios/withNotificationsXcodeProject.ts +56 -1
  98. package/plugin/src/ios/withXcodeProject.ts +20 -3
  99. package/plugin/src/types/cio-types.ts +38 -0
  100. package/plugin/src/utils/validation.ts +18 -1
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["cio-types.ts"],"sourcesContent":["/**\n * Properties set by the user in their app config file (e.g: app.json or app.plugin.js)\n * @public\n */\nexport type CustomerIOPluginProperties = {\n // (iOS only) Environment name and bundle identifier\n devTeam: string;\n iosDeploymentTarget: string;\n};\n\n/**\n * Plugin options for iOS platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsIOS = {\n iosPath: string;\n devTeam?: string;\n bundleVersion?: string;\n bundleShortVersion?: string;\n bundleIdentifier?: string;\n iosDeploymentTarget?: string;\n appleTeamId?: string;\n appName?: string;\n\n useFrameworks?: 'static' | 'dynamic';\n\n pushNotification?: CustomerIOPluginPushNotificationOptions;\n\n /**\n * @deprecated No longer has any effect. Use autoTrackPushEvents to control if push metrics should be automatically tracked by SDK.\n */\n handleNotificationClick?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoFetchDeviceToken instead\n */\n autoFetchDeviceToken?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.showPushAppInForeground instead\n */\n showPushAppInForeground?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.autoTrackPushEvents instead\n */\n autoTrackPushEvents?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.handleDeeplinkInKilledState instead\n */\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * @deprecated Property will be removed in the future. Use ios.pushNotification.disableNotificationRegistration instead\n */\n disableNotificationRegistration?: boolean;\n};\n\n/**\n * Plugin options for Android platform configuration\n * @public\n */\nexport type CustomerIOPluginOptionsAndroid = {\n androidPath: string;\n googleServicesFile?: string;\n setHighPriorityPushHandler?: boolean;\n pushNotification?: {\n channel?: {\n id?: string;\n name?: string;\n importance?: number;\n };\n };\n /**\n * Controls whether to disable Android 16 support by downgrading androidx dependencies.\n *\n * When true (default for Expo SDK 53), forces older androidx versions compatible with\n * Android API 35 and AGP 8.8.2, preventing Android 16 incompatibility errors.\n *\n * When false (default for Expo SDK 54+), allows newer androidx versions that support Android 16\n * but require Android API 36 and AGP 8.9.1+.\n *\n * If not specified, the plugin auto-detects based on Expo SDK version:\n * - Expo SDK ≤53: true (disables Android 16)\n * - Expo SDK ≥54: false (enables Android 16)\n */\n disableAndroid16Support?: boolean;\n};\n\n/**\n * Location tracking mode for the Customer.io SDK location module.\n * Location is off by default. Only used when location is enabled (plugin option location.enabled: true).\n * @public\n */\nexport type LocationTrackingMode = 'OFF' | 'MANUAL' | 'ON_APP_START';\n\n/**\n * SDK configuration options for auto initialization\n * @public\n */\nexport type NativeSDKConfig = {\n cdpApiKey: string; // Required\n region?: 'US' | 'EU'; // Default: 'US'. The workspace region set for your workspace on the Customer.io dashboard\n autoTrackDeviceAttributes?: boolean; // Default: true\n trackApplicationLifecycleEvents?: boolean; // Default: true\n screenViewUse?: 'all' | 'inapp'; // Default: 'all'. 'all': sent to server + in-app messages, 'inapp': in-app messages only\n logLevel?: 'none' | 'error' | 'info' | 'debug'; // Default: 'debug'. Controls SDK logging verbosity\n siteId?: string; // Optional, if only siteId defined, migrationSiteId = siteId\n migrationSiteId?: string; // Optional, if only migrationSiteId defined, siteId should be null\n /**\n * Location module config. Location is off by default; only applied when plugin option location.enabled is true.\n * trackingMode: 'MANUAL' (host app controls when location is captured, default),\n * 'ON_APP_START' (SDK captures once per launch when app becomes active), or 'OFF'.\n */\n location?: {\n trackingMode?: LocationTrackingMode;\n };\n};\n\n/**\n * Location is off by default. When true, enables the Customer.io SDK location native module (iOS Podfile location subspec,\n * Android gradle.properties flag). Permissions and privacy keys (Info.plist, AndroidManifest)\n * remain the host app's responsibility.\n * @public\n */\nexport type CustomerIOPluginLocationOptions = {\n enabled?: boolean;\n};\n\n/**\n * Combined plugin options for both iOS and Android platforms\n * @public\n */\nexport type CustomerIOPluginOptions = {\n config?: NativeSDKConfig; // If defined, enables auto initialization of native SDK\n android: CustomerIOPluginOptionsAndroid;\n ios: CustomerIOPluginOptionsIOS;\n /**\n * Location is off by default. When location.enabled is true, the plugin adds SDK build-time setup (Podfile location subspec,\n * gradle.properties). Host apps must add their own location permissions and privacy usage strings.\n */\n location?: CustomerIOPluginLocationOptions;\n};\n\n/**\n * Rich push configuration used to initialize Notification Service Extension (NSE) on the native side\n * @public\n */\nexport type RichPushConfig = {\n cdpApiKey: string;\n region?: string;\n};\n\n/**\n * Push notification configuration options\n * @public\n */\nexport type CustomerIOPluginPushNotificationOptions = {\n provider?: 'apn' | 'fcm';\n googleServicesFile?: string;\n useRichPush?: boolean;\n autoFetchDeviceToken?: boolean;\n autoTrackPushEvents?: boolean;\n showPushAppInForeground?: boolean;\n disableNotificationRegistration?: boolean;\n handleDeeplinkInKilledState?: boolean;\n\n /**\n * Rich push config should match the values used to initialize SDK in the app.\n * Optional if `config` is provided at the top level.\n */\n env?: RichPushConfig;\n\n /**\n * iOS App Group identifier shared between the host app and the Notification Service Extension.\n * When set, `.appGroupId(...)` is injected into the MessagingPushConfigBuilder, the identifier\n * is added to the host app entitlements, and an NSE entitlements file is written.\n * When omitted, the native SDK handles group discovery on its own and no entitlements are added.\n */\n appGroupId?: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.validateNativeSDKConfig = validateNativeSDKConfig;
7
+ exports.validatePushNotificationOptions = validatePushNotificationOptions;
7
8
  exports.validateRequired = validateRequired;
8
9
  exports.validateRichPushConfig = validateRichPushConfig;
9
10
  exports.validateString = validateString;
@@ -84,4 +85,16 @@ function validateRichPushConfig(config) {
84
85
  isValid = validateRegion(config === null || config === void 0 ? void 0 : config.region, 'region', context) && isValid;
85
86
  return isValid;
86
87
  }
88
+ function validatePushNotificationOptions(options) {
89
+ const context = 'PushNotification';
90
+ let isValid = true;
91
+ const appGroupId = options.appGroupId;
92
+ if (appGroupId !== undefined) {
93
+ isValid = validateString(appGroupId, 'appGroupId', context) && isValid;
94
+ if (isValid && !appGroupId.startsWith('group.')) {
95
+ _logger.logger.warn(`${context}: appGroupId "${appGroupId}" does not start with "group." — ensure this matches your Apple App Group entitlement.`);
96
+ }
97
+ }
98
+ return isValid;
99
+ }
87
100
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_logger","require","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","logger","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig"],"sources":["validation.ts"],"sourcesContent":["import type { NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`\n );\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${context}: ${fieldName} must be a boolean, received: ${value}`\n );\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validateRequired,\n validateRichPushConfig,\n validateString\n};\n\n"],"mappings":";;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAACC,OAAsB,EAAEC,cAA4B,EAAW;EAC/E,IAAID,OAAO,CAAC,CAAC,EAAE;IACb,OAAO,IAAI;EACb;;EAEA;EACA,MAAME,OAAO,GAAGD,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require","validate","isValid","messageFactory","message","process","env","CUSTOMERIO_STRICT_MODE","Error","logger","format","warn","isUndefined","value","undefined","validateRequired","fieldName","context","validateString","trim","validateBoolean","validateEnum","allowedValues","lowerValue","toLowerCase","lowerAllowedValues","map","v","includes","valuesStr","join","validateRegion","validateNativeSDKConfig","config","cdpApiKey","region","screenViewUse","logLevel","autoTrackDeviceAttributes","trackApplicationLifecycleEvents","siteId","migrationSiteId","validateRichPushConfig","validatePushNotificationOptions","options","appGroupId","startsWith"],"sources":["validation.ts"],"sourcesContent":["import type { CustomerIOPluginPushNotificationOptions, NativeSDKConfig, RichPushConfig } from '../types/cio-types';\nimport { logger } from './logger';\n\n/**\n * Validates a condition and handles errors based on CUSTOMERIO_STRICT_MODE flag.\n * @param isValid - Function that returns true if validation passes\n * @param messageFactory - Function that returns the error message if validation fails\n * @returns true if validation passes, false if it fails\n */\nfunction validate(isValid: () => boolean, messageFactory: () => string): boolean {\n if (isValid()) {\n return true;\n }\n\n // Throw errors unless explicitly disabled, default to strict validation\n const message = messageFactory();\n // Throw an error if strict mode is enabled, log a warning otherwise\n if (process.env.CUSTOMERIO_STRICT_MODE === 'true') {\n throw new Error(logger.format(message));\n } else {\n logger.warn(message);\n }\n return false;\n}\n\nfunction isUndefined(value: unknown): boolean {\n return value === undefined;\n}\n\nfunction validateRequired(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => !isUndefined(value) && value !== null,\n () => `${context}: ${fieldName} is required, received: ${value}`\n );\n}\n\nfunction validateString(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || (typeof value === 'string' && value.trim() !== ''),\n () => `${context}: ${fieldName} must be a non-empty string, received: ${typeof value === 'string' ? `\"${value}\"` : value}`\n );\n}\n\nfunction validateBoolean(value: unknown, fieldName: string, context: string): boolean {\n return validate(\n () => isUndefined(value) || typeof value === 'boolean',\n () => `${context}: ${fieldName} must be a boolean, received: ${value}`\n );\n}\n\nfunction validateEnum<T extends string>(\n value: unknown,\n fieldName: string,\n allowedValues: readonly T[],\n context: string\n): boolean {\n if (isUndefined(value)) return true;\n\n // First validate it's a string\n if (!validateString(value, fieldName, context)) {\n return false;\n }\n\n // Then validate it's in the allowed values\n return validate(\n () => {\n const lowerValue = (value as string).toLowerCase();\n const lowerAllowedValues = allowedValues.map(v => v.toLowerCase());\n return lowerAllowedValues.includes(lowerValue);\n },\n () => {\n const valuesStr = allowedValues.map(v => `\"${v}\"`).join(', ');\n return `${context}: ${fieldName} must be one of ${valuesStr}, received: ${value}`;\n }\n );\n}\n\nfunction validateRegion(value: unknown, fieldName: string, context: string): boolean {\n return validateEnum(value, fieldName, ['US', 'EU'], context);\n}\n\nfunction validateNativeSDKConfig(config: NativeSDKConfig): boolean {\n const context = 'NativeSDKConfig';\n\n let isValid = true;\n\n isValid = validateRequired(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config.region, 'region', context) && isValid;\n isValid = validateEnum(config.screenViewUse, 'screenViewUse', ['all', 'inapp'], context) && isValid;\n isValid = validateEnum(config.logLevel, 'logLevel', ['none', 'error', 'info', 'debug'], context) && isValid;\n isValid = validateBoolean(config.autoTrackDeviceAttributes, 'autoTrackDeviceAttributes', context) && isValid;\n isValid = validateBoolean(config.trackApplicationLifecycleEvents, 'trackApplicationLifecycleEvents', context) && isValid;\n isValid = validateString(config.siteId, 'siteId', context) && isValid;\n isValid = validateString(config.migrationSiteId, 'migrationSiteId', context) && isValid;\n\n return isValid;\n}\n\nfunction validateRichPushConfig(config: RichPushConfig | undefined): boolean {\n const context = 'NotificationServiceExtension';\n\n let isValid = true;\n\n isValid = validateRequired(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateString(config?.cdpApiKey, 'cdpApiKey', context) && isValid;\n isValid = validateRegion(config?.region, 'region', context) && isValid;\n\n return isValid;\n}\n\nfunction validatePushNotificationOptions(options: CustomerIOPluginPushNotificationOptions): boolean {\n const context = 'PushNotification';\n\n let isValid = true;\n\n const appGroupId = options.appGroupId;\n if (appGroupId !== undefined) {\n isValid = validateString(appGroupId, 'appGroupId', context) && isValid;\n if (isValid && !appGroupId.startsWith('group.')) {\n logger.warn(`${context}: appGroupId \"${appGroupId}\" does not start with \"group.\" — ensure this matches your Apple App Group entitlement.`);\n }\n }\n\n return isValid;\n}\n\nexport {\n validateNativeSDKConfig,\n validatePushNotificationOptions,\n validateRequired,\n validateRichPushConfig,\n validateString\n};\n\n"],"mappings":";;;;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAACC,OAAsB,EAAEC,cAA4B,EAAW;EAC/E,IAAID,OAAO,CAAC,CAAC,EAAE;IACb,OAAO,IAAI;EACb;;EAEA;EACA,MAAME,OAAO,GAAGD,cAAc,CAAC,CAAC;EAChC;EACA,IAAIE,OAAO,CAACC,GAAG,CAACC,sBAAsB,KAAK,MAAM,EAAE;IACjD,MAAM,IAAIC,KAAK,CAACC,cAAM,CAACC,MAAM,CAACN,OAAO,CAAC,CAAC;EACzC,CAAC,MAAM;IACLK,cAAM,CAACE,IAAI,CAACP,OAAO,CAAC;EACtB;EACA,OAAO,KAAK;AACd;AAEA,SAASQ,WAAWA,CAACC,KAAc,EAAW;EAC5C,OAAOA,KAAK,KAAKC,SAAS;AAC5B;AAEA,SAASC,gBAAgBA,CAACF,KAAc,EAAEG,SAAiB,EAAEC,OAAe,EAAW;EACrF,OAAOhB,QAAQ,CACb,MAAM,CAACW,WAAW,CAACC,KAAK,CAAC,IAAIA,KAAK,KAAK,IAAI,EAC3C,MAAM,GAAGI,OAAO,KAAKD,SAAS,2BAA2BH,KAAK,EAChE,CAAC;AACH;AAEA,SAASK,cAAcA,CAACL,KAAc,EAAEG,SAAiB,EAAEC,OAAe,EAAW;EACnF,OAAOhB,QAAQ,CACb,MAAMW,WAAW,CAACC,KAAK,CAAC,IAAK,OAAOA,KAAK,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,sBAAsBA,CAACT,MAAkC,EAAW;EAC3E,MAAMhB,OAAO,GAAG,8BAA8B;EAE9C,IAAIf,OAAO,GAAG,IAAI;EAElBA,OAAO,GAAGa,gBAAgB,CAACkB,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEC,SAAS,EAAE,WAAW,EAAEjB,OAAO,CAAC,IAAIf,OAAO;EAC9EA,OAAO,GAAGgB,cAAc,CAACe,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEC,SAAS,EAAE,WAAW,EAAEjB,OAAO,CAAC,IAAIf,OAAO;EAC5EA,OAAO,GAAG6B,cAAc,CAACE,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,EAAE,QAAQ,EAAElB,OAAO,CAAC,IAAIf,OAAO;EAEtE,OAAOA,OAAO;AAChB;AAEA,SAASyC,+BAA+BA,CAACC,OAAgD,EAAW;EAClG,MAAM3B,OAAO,GAAG,kBAAkB;EAElC,IAAIf,OAAO,GAAG,IAAI;EAElB,MAAM2C,UAAU,GAAGD,OAAO,CAACC,UAAU;EACrC,IAAIA,UAAU,KAAK/B,SAAS,EAAE;IAC5BZ,OAAO,GAAGgB,cAAc,CAAC2B,UAAU,EAAE,YAAY,EAAE5B,OAAO,CAAC,IAAIf,OAAO;IACtE,IAAIA,OAAO,IAAI,CAAC2C,UAAU,CAACC,UAAU,CAAC,QAAQ,CAAC,EAAE;MAC/CrC,cAAM,CAACE,IAAI,CAAC,GAAGM,OAAO,iBAAiB4B,UAAU,wFAAwF,CAAC;IAC5I;EACF;EAEA,OAAO3C,OAAO;AAChB","ignoreList":[]}
@@ -1,12 +1,13 @@
1
1
  import { withAndroidManifestUpdates } from './withAndroidManifestUpdates';
2
2
  import { withAppGoogleServices } from './withAppGoogleServices';
3
3
  import { withGoogleServicesJSON } from './withGoogleServicesJSON';
4
+ import { withLocationGradleProperties } from './withLocationGradleProperties';
4
5
  import { withMainApplicationModifications } from './withMainApplicationModifications';
5
6
  import { withNotificationChannelMetadata } from './withNotificationChannelMetadata';
6
7
  import { withProjectBuildGradle } from './withProjectBuildGradle';
7
8
  import { withProjectGoogleServices } from './withProjectGoogleServices';
8
9
  import { withProjectStrings } from './withProjectStrings';
9
- export function withCIOAndroid(config, sdkConfig, props) {
10
+ export function withCIOAndroid(config, sdkConfig, props, location) {
10
11
  // Only run notification setup if props are provided
11
12
  if (props) {
12
13
  var _props$pushNotificati;
@@ -23,7 +24,10 @@ export function withCIOAndroid(config, sdkConfig, props) {
23
24
 
24
25
  // Add auto initialization if sdkConfig is provided
25
26
  if (sdkConfig) {
26
- config = withMainApplicationModifications(config, sdkConfig);
27
+ config = withMainApplicationModifications(config, {
28
+ sdkConfig,
29
+ location
30
+ });
27
31
  }
28
32
 
29
33
  // Update project strings for user agent metadata
@@ -32,6 +36,13 @@ export function withCIOAndroid(config, sdkConfig, props) {
32
36
  // Add dependency resolution strategy for Expo SDK 53 compatibility
33
37
  // This prevents androidx versions that require API 36 from being pulled in
34
38
  config = withProjectBuildGradle(config, props);
39
+
40
+ // Enable SDK location module when location.enabled is true
41
+ if ((location === null || location === void 0 ? void 0 : location.enabled) === true) {
42
+ config = withLocationGradleProperties(config, {
43
+ location
44
+ });
45
+ }
35
46
  return config;
36
47
  }
37
48
  //# sourceMappingURL=withCIOAndroid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGoogleServicesJSON","withMainApplicationModifications","withNotificationChannelMetadata","withProjectBuildGradle","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","setHighPriorityPushHandler","undefined","pushNotification","channel"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsAndroid, NativeSDKConfig } from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectBuildGradle } from './withProjectBuildGradle';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsAndroid,\n): ExpoConfig {\n // Only run notification setup if props are provided\n if (props) {\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n }\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, sdkConfig);\n }\n\n // Update project strings for user agent metadata\n config = withProjectStrings(config);\n\n // Add dependency resolution strategy for Expo SDK 53 compatibility\n // This prevents androidx versions that require API 36 from being pulled in\n config = withProjectBuildGradle(config, props);\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAsC,EAC1B;EACZ;EACA,IAAIA,KAAK,EAAE;IAAA,IAAAC,qBAAA;IACTH,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEE,KAAK,CAAC;IACjDF,MAAM,GAAGR,qBAAqB,CAACQ,MAAM,EAAEE,KAAK,CAAC;IAC7CF,MAAM,GAAGP,sBAAsB,CAACO,MAAM,EAAEE,KAAK,CAAC;IAC9C,IAAIA,KAAK,CAACE,0BAA0B,KAAKC,SAAS,EAAE;MAClDL,MAAM,GAAGT,0BAA0B,CAACS,MAAM,EAAEE,KAAK,CAAC;IACpD;IACA,KAAAC,qBAAA,GAAID,KAAK,CAACI,gBAAgB,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,OAAO,EAAE;MACnCP,MAAM,GAAGL,+BAA+B,CAACK,MAAM,EAAEE,KAAK,CAAC;IACzD;EACF;;EAEA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAGN,gCAAgC,CAACM,MAAM,EAAEC,SAAS,CAAC;EAC9D;;EAEA;EACAD,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;;EAEnC;EACA;EACAA,MAAM,GAAGJ,sBAAsB,CAACI,MAAM,EAAEE,KAAK,CAAC;EAE9C,OAAOF,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["withAndroidManifestUpdates","withAppGoogleServices","withGoogleServicesJSON","withLocationGradleProperties","withMainApplicationModifications","withNotificationChannelMetadata","withProjectBuildGradle","withProjectGoogleServices","withProjectStrings","withCIOAndroid","config","sdkConfig","props","location","_props$pushNotificati","setHighPriorityPushHandler","undefined","pushNotification","channel","enabled"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {\n CustomerIOPluginOptionsAndroid,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withLocationGradleProperties } from './withLocationGradleProperties';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectBuildGradle } from './withProjectBuildGradle';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsAndroid,\n location?: CustomerIOPluginLocationOptions,\n): ExpoConfig {\n // Only run notification setup if props are provided\n if (props) {\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n }\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, { sdkConfig, location });\n }\n\n // Update project strings for user agent metadata\n config = withProjectStrings(config);\n\n // Add dependency resolution strategy for Expo SDK 53 compatibility\n // This prevents androidx versions that require API 36 from being pulled in\n config = withProjectBuildGradle(config, props);\n\n // Enable SDK location module when location.enabled is true\n if (location?.enabled === true) {\n config = withLocationGradleProperties(config, { location });\n }\n\n return config;\n}\n"],"mappings":"AAOA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,gCAAgC,QAAQ,oCAAoC;AACrF,SAASC,+BAA+B,QAAQ,mCAAmC;AACnF,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AAEzD,OAAO,SAASC,cAAcA,CAC5BC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAsC,EACtCC,QAA0C,EAC9B;EACZ;EACA,IAAID,KAAK,EAAE;IAAA,IAAAE,qBAAA;IACTJ,MAAM,GAAGH,yBAAyB,CAACG,MAAM,EAAEE,KAAK,CAAC;IACjDF,MAAM,GAAGT,qBAAqB,CAACS,MAAM,EAAEE,KAAK,CAAC;IAC7CF,MAAM,GAAGR,sBAAsB,CAACQ,MAAM,EAAEE,KAAK,CAAC;IAC9C,IAAIA,KAAK,CAACG,0BAA0B,KAAKC,SAAS,EAAE;MAClDN,MAAM,GAAGV,0BAA0B,CAACU,MAAM,EAAEE,KAAK,CAAC;IACpD;IACA,KAAAE,qBAAA,GAAIF,KAAK,CAACK,gBAAgB,cAAAH,qBAAA,eAAtBA,qBAAA,CAAwBI,OAAO,EAAE;MACnCR,MAAM,GAAGL,+BAA+B,CAACK,MAAM,EAAEE,KAAK,CAAC;IACzD;EACF;;EAEA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAGN,gCAAgC,CAACM,MAAM,EAAE;MAAEC,SAAS;MAAEE;IAAS,CAAC,CAAC;EAC5E;;EAEA;EACAH,MAAM,GAAGF,kBAAkB,CAACE,MAAM,CAAC;;EAEnC;EACA;EACAA,MAAM,GAAGJ,sBAAsB,CAACI,MAAM,EAAEE,KAAK,CAAC;;EAE9C;EACA,IAAI,CAAAC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEM,OAAO,MAAK,IAAI,EAAE;IAC9BT,MAAM,GAAGP,4BAA4B,CAACO,MAAM,EAAE;MAAEG;IAAS,CAAC,CAAC;EAC7D;EAEA,OAAOH,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,30 @@
1
+ import { withGradleProperties } from '@expo/config-plugins';
2
+ const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
3
+
4
+ /**
5
+ * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
6
+ * The Customer.io React Native SDK reads this to enable the location native module.
7
+ */
8
+ export const withLocationGradleProperties = (config, props) => {
9
+ var _props$location;
10
+ if ((props === null || props === void 0 || (_props$location = props.location) === null || _props$location === void 0 ? void 0 : _props$location.enabled) !== true) {
11
+ return config;
12
+ }
13
+ return withGradleProperties(config, config => {
14
+ const items = config.modResults;
15
+ const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
16
+ const newItem = {
17
+ type: 'property',
18
+ key: CUSTOMERIO_LOCATION_ENABLED_KEY,
19
+ value: 'true'
20
+ };
21
+ if (existingIndex >= 0) {
22
+ items[existingIndex] = newItem;
23
+ } else {
24
+ items.push(newItem);
25
+ }
26
+ config.modResults = items;
27
+ return config;
28
+ });
29
+ };
30
+ //# sourceMappingURL=withLocationGradleProperties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["withGradleProperties","CUSTOMERIO_LOCATION_ENABLED_KEY","withLocationGradleProperties","config","props","_props$location","location","enabled","items","modResults","existingIndex","findIndex","item","type","key","newItem","value","push"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n config.modResults = items;\n return config;\n });\n};\n"],"mappings":"AACA,SAASA,oBAAoB,QAAQ,sBAAsB;AAK3D,MAAMC,+BAA+B,GAAG,6BAA6B;;AAErE;AACA;AACA;AACA;AACA,OAAO,MAAMC,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAOH,oBAAoB,CAACG,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMK,KAAK,GAAGL,MAAM,CAACM,UAA8B;IACnD,MAAMC,aAAa,GAAGF,KAAK,CAACG,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKb,+BACrD,CAAC;IAED,MAAMc,OAAuB,GAAG;MAC9BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAEb,+BAA+B;MACpCe,KAAK,EAAE;IACT,CAAC;IAED,IAAIN,aAAa,IAAI,CAAC,EAAE;MACtBF,KAAK,CAACE,aAAa,CAAC,GAAGK,OAAO;IAChC,CAAC,MAAM;MACLP,KAAK,CAACS,IAAI,CAACF,OAAO,CAAC;IACrB;IAEAZ,MAAM,CAACM,UAAU,GAAGD,KAAK;IACzB,OAAOL,MAAM;EACf,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -4,26 +4,42 @@ import { PLATFORM } from '../helpers/constants/common';
4
4
  import { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';
5
5
  import { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';
6
6
  import { logger } from '../utils/logger';
7
- export const withMainApplicationModifications = (configOuter, sdkConfig) => {
7
+ export const withMainApplicationModifications = (configOuter, {
8
+ sdkConfig,
9
+ location
10
+ }) => {
8
11
  return withMainApplication(configOuter, async config => {
9
- const content = setupCustomerIOSDKInitializer(config, sdkConfig);
12
+ const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);
10
13
  config.modResults.contents = content;
11
14
  return config;
12
15
  });
13
16
  };
14
17
 
18
+ /**
19
+ * Build location options for native initializer from plugin config.
20
+ * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).
21
+ */
22
+ const getLocationInitOptions = (location, sdkConfig) => {
23
+ var _sdkConfig$location;
24
+ return {
25
+ enabled: (location === null || location === void 0 ? void 0 : location.enabled) === true,
26
+ trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
27
+ };
28
+ };
29
+
15
30
  /**
16
31
  * Setup CustomerIOSDKInitializer for Android auto initialization
17
32
  */
18
- const setupCustomerIOSDKInitializer = (config, sdkConfig) => {
33
+ const setupCustomerIOSDKInitializer = (config, sdkConfig, location) => {
19
34
  const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
20
35
  const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
21
36
  const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
22
37
  const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
38
+ const locationOptions = getLocationInitOptions(location, sdkConfig);
23
39
  let content = config.modResults.contents;
24
40
  try {
25
41
  // Always regenerate the CustomerIOSDKInitializer file to reflect config changes
26
- copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig));
42
+ copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions));
27
43
  // Add import if not already present
28
44
  content = addImportToFile(content, SDK_INITIALIZER_IMPORT);
29
45
  // Add initialization code to onCreate if not already present
@@ -1 +1 @@
1
- {"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","config","content","setupCustomerIOSDKInitializer","modResults","contents","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","ANDROID","includes","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type { NativeSDKConfig } from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\nexport const withMainApplicationModifications: ConfigPlugin<NativeSDKConfig> = (configOuter, sdkConfig) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAElF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AACrF,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,MAAMC,gCAA+D,GAAGA,CAACC,WAAW,EAAEC,SAAS,KAAK;EACzG,OAAOZ,mBAAmB,CAACW,WAAW,EAAE,MAAOE,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAED,SAAS,CAAC;IAChEC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA,MAAME,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDD,SAA0B,KACf;EACX,MAAMM,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,IAAIJ,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACAT,gBAAgB,CAACK,MAAM,EAAEO,oBAAoB,EAAED,uBAAuB,EAAGL,OAAO,IAC9ET,yBAAyB,CAACS,OAAO,EAAEV,QAAQ,CAACkB,OAAO,EAAEV,SAAS,CAChE,CAAC;IACD;IACAE,OAAO,GAAGP,eAAe,CAACO,OAAO,EAAEO,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACP,OAAO,CAACS,QAAQ,CAACrB,8BAA8B,CAAC,EAAE;MACrDY,OAAO,GAAGR,eAAe,CAACQ,OAAO,EAAEb,kCAAkC,EAAEE,iCAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOqB,KAAK,EAAE;IACdf,MAAM,CAACgB,IAAI,CAAC,mBAAmBP,qBAAqB,GAAG,EAAEM,KAAK,CAAC;IAC/D,OAAOX,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["withMainApplication","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_CALL","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","PLATFORM","patchNativeSDKInitializer","addCodeToMethod","addImportToFile","copyTemplateFile","logger","withMainApplicationModifications","configOuter","sdkConfig","location","config","content","setupCustomerIOSDKInitializer","modResults","contents","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","locationOptions","ANDROID","includes","error","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,sBAAsB;AAE1D,SAASC,kCAAkC,EAAEC,8BAA8B,EAAEC,iCAAiC,QAAQ,8BAA8B;AACpJ,SAASC,QAAQ,QAAQ,6BAA6B;AACtD,SAASC,yBAAyB,QAAQ,wCAAwC;AAKlF,SAASC,eAAe,EAAEC,eAAe,EAAEC,gBAAgB,QAAQ,kBAAkB;AACrF,SAASC,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAMC,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS,CAAC,KAAK;EAChI,OAAOb,mBAAmB,CAACW,WAAW,EAAE,MAAOG,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEF,SAAS,EAAEC,QAAQ,CAAC;IAC1EC,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAMK,sBAAsB,GAAGA,CAC7BN,QAA0C,EAC1CD,SAA2B;EAAA,IAAAQ,mBAAA;EAAA,OACvB;IACJC,OAAO,EAAE,CAAAR,QAAQ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+7,7 @@ import io.customer.messaginginapp.ModuleMessagingInApp
7
7
  import io.customer.messagingpush.MessagingPushModuleConfig
8
8
  import io.customer.messagingpush.ModuleMessagingPushFCM
9
9
  import io.customer.reactnative.sdk.messaginginapp.ReactInAppEventListener
10
+ {{LOCATION_MODULE_IMPORT}}
10
11
  import io.customer.sdk.CustomerIOBuilder
11
12
  import io.customer.sdk.core.util.CioLogLevel
12
13
  import io.customer.sdk.data.model.Region
@@ -41,6 +42,7 @@ object CustomerIOSDKInitializer {
41
42
  MessagingPushModuleConfig.Builder().build()
42
43
  )
43
44
  )
45
+ {{LOCATION_MODULE_INIT}}
44
46
 
45
47
  build()
46
48
  }
@@ -1,6 +1,7 @@
1
1
  import CioDataPipelines
2
2
  import CioInternalCommon
3
3
  import CioMessagingInApp
4
+ {{LOCATION_MODULE_IMPORT}}
4
5
 
5
6
  class CustomerIOSDKInitializer {
6
7
  static func initialize() {
@@ -23,6 +24,7 @@ class CustomerIOSDKInitializer {
23
24
  setIfDefined(value: {{SCREEN_VIEW_USE}}, thenPassItTo: builder.screenViewUse) { ScreenView.getScreenView($0) }
24
25
  setIfDefined(value: {{MIGRATION_SITE_ID}}, thenPassItTo: builder.migrationSiteId)
25
26
 
27
+ {{LOCATION_MODULE_INIT}}
26
28
  CustomerIO.initialize(withConfig: builder.build())
27
29
 
28
30
  if let siteId = siteId {
@@ -42,7 +42,7 @@ public class CioSdkAppDelegateHandler: NSObject {
42
42
  MessagingPushAPN.initialize(
43
43
  withConfig: MessagingPushConfigBuilder()
44
44
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
45
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
45
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
46
46
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
47
47
  .build()
48
48
  )
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
12
12
  MessagingPushAPN.initializeForExtension(
13
13
  withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
14
14
  .region(Env.customerIORegion)
15
- .build()
15
+ {{APP_GROUP_ID_BUILDER_LINE}} .build()
16
16
  )
17
17
 
18
18
  MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
@@ -15,7 +15,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
15
15
  MessagingPushAPN.initialize(
16
16
  withConfig: MessagingPushConfigBuilder()
17
17
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
18
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
18
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
19
19
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
20
20
  .build()
21
21
  )
@@ -52,7 +52,7 @@ public class CioSdkAppDelegateHandler: NSObject {
52
52
  MessagingPushFCM.initialize(
53
53
  withConfig: MessagingPushConfigBuilder()
54
54
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
55
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
55
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
56
56
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
57
57
  .build()
58
58
  )
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
12
12
  MessagingPushFCM.initializeForExtension(
13
13
  withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
14
14
  .region(Env.customerIORegion)
15
- .build()
15
+ {{APP_GROUP_ID_BUILDER_LINE}} .build()
16
16
  )
17
17
 
18
18
  MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
@@ -23,7 +23,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
23
23
  MessagingPushFCM.initialize(
24
24
  withConfig: MessagingPushConfigBuilder()
25
25
  .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
26
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
26
+ {{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
27
27
  .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
28
28
  .build()
29
29
  )
@@ -2,7 +2,22 @@ import { logger } from '../../utils/logger';
2
2
  import { getRelativePathToRNSDK } from '../constants/ios';
3
3
  import { injectCodeByRegex } from './codeInjection';
4
4
  import { FileManagement } from './fileManagement';
5
- export async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
5
+ /** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
6
+ export function buildHostAppPodSnippet(iosPath, isFcmPushProvider, options) {
7
+ const path = getRelativePathToRNSDK(iosPath);
8
+ const locationEnabled = (options === null || options === void 0 ? void 0 : options.locationEnabled) === true;
9
+ const hasPush = (options === null || options === void 0 ? void 0 : options.hasPush) !== false;
10
+ if (!locationEnabled) {
11
+ const subspec = isFcmPushProvider ? 'fcm' : 'apn';
12
+ return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;
13
+ }
14
+ if (!hasPush) {
15
+ return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;
16
+ }
17
+ const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';
18
+ return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;
19
+ }
20
+ export async function injectCIOPodfileCode(iosPath, isFcmPushProvider, options) {
6
21
  const blockStart = '# --- CustomerIO Host App START ---';
7
22
  const blockEnd = '# --- CustomerIO Host App END ---';
8
23
  const filename = `${iosPath}/Podfile`;
@@ -13,9 +28,10 @@ export async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
13
28
  // The "post_install" line is always present in an Expo project Podfile so it's reliable.
14
29
  // Find that line in the Podfile and then we will insert our code above that line.
15
30
  const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
31
+ const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);
16
32
  const snippetToInjectInPodfile = `
17
33
  ${blockStart}
18
- pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'}', :path => '${getRelativePathToRNSDK(iosPath)}'
34
+ ${podLine}
19
35
  ${blockEnd}
20
36
  `.trim();
21
37
  FileManagement.write(filename, injectCodeByRegex(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
@@ -1 +1 @@
1
- {"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","trim","write","join","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 async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean\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 snippetToInjectInPodfile = `\n${blockStart}\n pod 'customerio-reactnative/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\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,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoBA,CACxCC,OAAe,EACfC,iBAA0B,EAC1B;EACA,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ,gCAAgCD,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAC3CL,sBAAsB,CAACI,OAAO,CAAC;AACrD,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACe,KAAK,CAClBT,QAAQ,EACRP,iBAAiB,CACfQ,OAAO,EACPK,kCAAkC,EAClCC,wBACF,CAAC,CAACG,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLnB,MAAM,CAACoB,IAAI,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDhB,OAAe,EACfiB,aAA0D,EAC1DhB,iBAA0B,EAC1B;EACA,MAAMG,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMP,cAAc,CAACQ,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAET,UAAU;AACZ;AACA,IAAIe,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyChB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpDL,sBAAsB,CAACI,OAAO,CAAC;AACrD;AACA,EAAEG,QAAQ;AACV,CAAC,CAACS,IAAI,CAAC,CAAC;IAEJd,cAAc,CAACoB,MAAM,CAACd,QAAQ,EAAEO,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
1
+ {"version":3,"names":["logger","getRelativePathToRNSDK","injectCodeByRegex","FileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","path","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","join","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,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SAASC,cAAc,QAAQ,kBAAkB;AASjD;AACA,OAAO,SAASC,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACzB;EACR,MAAMC,IAAI,GAAGP,sBAAsB,CAACI,OAAO,CAAC;EAC5C,MAAMI,eAAe,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE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ACL3B,MAAM,CAAC4B,IAAI,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgCA,CACpDxB,OAAe,EACfyB,aAA0D,EAC1DxB,iBAA0B,EAC1B;EACA,MAAMU,QAAQ,GAAG,GAAGX,OAAO,UAAU;EACrC,MAAMY,OAAO,GAAG,MAAMd,cAAc,CAACe,IAAI,CAACF,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMI,OAAO,GAAGF,OAAO,CAACG,KAAK,CAAC,IAAIC,MAAM,CAACP,UAAU,CAAC,CAAC;EAErD,IAAI,CAACK,OAAO,EAAE;IACZ,MAAMK,wBAAwB,GAAG;AACrC,EAAEV,UAAU;AACZ;AACA,IAAIgB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCxB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpDL,sBAAsB,CAACI,OAAO,CAAC;AACrD;AACA,EAAEU,QAAQ;AACV,CAAC,CAACU,IAAI,CAAC,CAAC;IAEJtB,cAAc,CAAC4B,MAAM,CAACf,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import { PLATFORM } from '../constants/common';
2
+ const VALID_TRACKING_MODES = ['OFF', 'MANUAL', 'ON_APP_START'];
3
+
4
+ /** Options for location module in generated native initializer */
5
+
6
+ function normalizeTrackingMode(rawMode) {
7
+ const upper = rawMode === null || rawMode === void 0 ? void 0 : rawMode.toUpperCase();
8
+ return upper && VALID_TRACKING_MODES.includes(upper) ? upper : 'MANUAL';
9
+ }
10
+
11
+ /**
12
+ * Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders
13
+ * in SDK initializer template content for the given platform.
14
+ */
15
+ export function patchLocationPlaceholders(content, platform, locationOptions) {
16
+ const locationEnabled = (locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.enabled) === true;
17
+ const trackingMode = normalizeTrackingMode(locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.trackingMode);
18
+ if (platform === PLATFORM.ANDROID) {
19
+ if (locationEnabled) {
20
+ return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, `import io.customer.location.LocationModuleConfig
21
+ import io.customer.location.LocationTrackingMode
22
+ import io.customer.location.ModuleLocation
23
+ `).replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {
24
+ addCustomerIOModule(
25
+ ModuleLocation(
26
+ LocationModuleConfig.Builder()
27
+ .setLocationTrackingMode(LocationTrackingMode.${trackingMode})
28
+ .build()
29
+ )
30
+ )
31
+ }
32
+ `);
33
+ }
34
+ return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n');
35
+ }
36
+
37
+ // iOS
38
+ if (locationEnabled) {
39
+ const modeSwift = trackingMode === 'OFF' ? '.off' : trackingMode === 'ON_APP_START' ? '.onAppStart' : '.manual';
40
+ return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, 'import CioLocation\n').replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`);
41
+ }
42
+ return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n\n');
43
+ }
44
+ //# sourceMappingURL=patchLocationCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PLATFORM","VALID_TRACKING_MODES","normalizeTrackingMode","rawMode","upper","toUpperCase","includes","patchLocationPlaceholders","content","platform","locationOptions","locationEnabled","enabled","trackingMode","ANDROID","replace","modeSwift"],"sources":["patchLocationCode.ts"],"sourcesContent":["import type { LocationTrackingMode } from '../../types/cio-types';\nimport { PLATFORM, type Platform } from '../constants/common';\n\nconst VALID_TRACKING_MODES: LocationTrackingMode[] = ['OFF', 'MANUAL', 'ON_APP_START'];\n\n/** Options for location module in generated native initializer */\nexport type LocationInitOptions = {\n enabled: boolean;\n trackingMode?: LocationTrackingMode;\n};\n\nfunction normalizeTrackingMode(\n rawMode: string | undefined\n): LocationTrackingMode {\n const upper = rawMode?.toUpperCase();\n return upper && VALID_TRACKING_MODES.includes(upper as LocationTrackingMode)\n ? (upper as LocationTrackingMode)\n : 'MANUAL';\n}\n\n/**\n * Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders\n * in SDK initializer template content for the given platform.\n */\nexport function patchLocationPlaceholders(\n content: string,\n platform: Platform,\n locationOptions?: LocationInitOptions\n): string {\n const locationEnabled = locationOptions?.enabled === true;\n const trackingMode = normalizeTrackingMode(locationOptions?.trackingMode);\n\n if (platform === PLATFORM.ANDROID) {\n if (locationEnabled) {\n return content\n .replace(\n /\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g,\n `import io.customer.location.LocationModuleConfig\nimport io.customer.location.LocationTrackingMode\nimport io.customer.location.ModuleLocation\n`\n )\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {\n addCustomerIOModule(\n ModuleLocation(\n LocationModuleConfig.Builder()\n .setLocationTrackingMode(LocationTrackingMode.${trackingMode})\n .build()\n )\n )\n }\n `\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n');\n }\n\n // iOS\n if (locationEnabled) {\n const modeSwift =\n trackingMode === 'OFF'\n ? '.off'\n : trackingMode === 'ON_APP_START'\n ? '.onAppStart'\n : '.manual';\n return content\n .replace(/\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g, 'import CioLocation\\n')\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n\\n');\n}\n"],"mappings":"AACA,SAASA,QAAQ,QAAuB,qBAAqB;AAE7D,MAAMC,oBAA4C,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC;;AAEtF;;AAMA,SAASC,qBAAqBA,CAC5BC,OAA2B,EACL;EACtB,MAAMC,KAAK,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,WAAW,CAAC,CAAC;EACpC,OAAOD,KAAK,IAAIH,oBAAoB,CAACK,QAAQ,CAACF,KAA6B,CAAC,GACvEA,KAAK,GACN,QAAQ;AACd;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASG,yBAAyBA,CACvCC,OAAe,EACfC,QAAkB,EAClBC,eAAqC,EAC7B;EACR,MAAMC,eAAe,GAAG,CAAAD,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEE,OAAO,MAAK,IAAI;EACzD,MAAMC,YAAY,GAAGX,qBAAqB,CAACQ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEG,YAAY,CAAC;EAEzE,IAAIJ,QAAQ,KAAKT,QAAQ,CAACc,OAAO,EAAE;IACjC,IAAIH,eAAe,EAAE;MACnB,OAAOH,OAAO,CACXO,OAAO,CACN,iCAAiC,EACjC;AACV;AACA;AACA,CACQ,CAAC,CACAA,OAAO,CACN,+BAA+B,EAC/B;AACV;AACA;AACA;AACA,wEAAwEF,YAAY;AACpF;AACA;AACA;AACA;AACA,SACQ,CAAC;IACL;IACA,OAAOL,OAAO,CACXO,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,IAAI,CAAC;EAC1D;;EAEA;EACA,IAAIJ,eAAe,EAAE;IACnB,MAAMK,SAAS,GACbH,YAAY,KAAK,KAAK,GAClB,MAAM,GACNA,YAAY,KAAK,cAAc,GAC7B,aAAa,GACb,SAAS;IACjB,OAAOL,OAAO,CACXO,OAAO,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAClEA,OAAO,CACN,+BAA+B,EAC/B,qEAAqEC,SAAS,KAChF,CAAC;EACL;EACA,OAAOR,OAAO,CACXO,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,MAAM,CAAC;AAC5D","ignoreList":[]}
@@ -1,12 +1,12 @@
1
1
  import { getPluginVersion } from '../../utils/plugin';
2
2
  import { validateNativeSDKConfig } from '../../utils/validation';
3
3
  import { PLATFORM } from '../constants/common';
4
-
4
+ import { patchLocationPlaceholders } from './patchLocationCode';
5
5
  /**
6
6
  * Shared utility function to perform common SDK config replacements
7
7
  * for both iOS and Android template files
8
8
  */
9
- export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
9
+ export function patchNativeSDKInitializer(rawContent, platform, sdkConfig, locationOptions) {
10
10
  var _siteId, _migrationSiteId;
11
11
  // Validate SDK configuration to ensure all fields are present and
12
12
  // correct at the time of patching in prebuild
@@ -56,6 +56,7 @@ export function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
56
56
  // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)
57
57
  replaceValue(/\{\{SITE_ID\}\}/g, ((_siteId = siteId) === null || _siteId === void 0 ? void 0 : _siteId.trim()) || undefined, configValue => `"${configValue}"`);
58
58
  replaceValue(/\{\{MIGRATION_SITE_ID\}\}/g, ((_migrationSiteId = migrationSiteId) === null || _migrationSiteId === void 0 ? void 0 : _migrationSiteId.trim()) || undefined, configValue => `"${configValue}"`);
59
+ content = patchLocationPlaceholders(content, platform, locationOptions);
59
60
  return content;
60
61
  }
61
62
  //# sourceMappingURL=patchPluginNativeCode.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getPluginVersion","validateNativeSDKConfig","PLATFORM","patchNativeSDKInitializer","rawContent","platform","sdkConfig","_siteId","_migrationSiteId","content","replaceValue","placeholder","value","transform","fallback","ANDROID","undefined","replace","pluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n return content;\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SAASC,QAAQ,QAAuB,qBAAqB;;AAE7D;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,UAAkB,EAClBC,QAAkB,EAClBC,SAA0B,EAClB;EAAA,IAAAC,OAAA,EAAAC,gBAAA;EACR;EACA;EACAP,uBAAuB,CAACK,SAAS,CAAC;EAElC,IAAIG,OAAO,GAAGL,UAAU;;EAExB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CAACqB,MAAM;EAC7B,IAAIC,eAAe,GAAGtB,SAAS,CAACsB,eAAe;;EAE/C;EACA,IAAID,MAAM,IAAI,CAACC,eAAe,EAAE;IAC9BA,eAAe,GAAGD,MAAM;EAC1B,CAAC,MAAM,IAAIC,eAAe,IAAI,CAACD,MAAM,EAAE;IACrCA,MAAM,GAAGX,SAAS;EACpB;;EAEA;EACAN,YAAY,CACV,kBAAkB,EAClB,EAAAH,OAAA,GAAAoB,MAAM,cAAApB,OAAA,uBAANA,OAAA,CAAQsB,IAAI,CAAC,CAAC,KAAIb,SAAS,EAC1BK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDX,YAAY,CACV,4BAA4B,EAC5B,EAAAF,gBAAA,GAAAoB,eAAe,cAAApB,gBAAA,uBAAfA,gBAAA,CAAiBqB,IAAI,CAAC,CAAC,KAAIb,SAAS,EACnCK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAED,OAAOZ,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"names":["getPluginVersion","validateNativeSDKConfig","PLATFORM","patchLocationPlaceholders","patchNativeSDKInitializer","rawContent","platform","sdkConfig","locationOptions","_siteId","_migrationSiteId","content","replaceValue","placeholder","value","transform","fallback","ANDROID","undefined","replace","pluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\nimport {\n type LocationInitOptions,\n patchLocationPlaceholders,\n} from './patchLocationCode';\n\nexport type { LocationInitOptions };\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig,\n locationOptions?: LocationInitOptions\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n content = patchLocationPlaceholders(content, platform, locationOptions);\n\n return content;\n}\n"],"mappings":"AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,QAAQ,wBAAwB;AAChE,SAASC,QAAQ,QAAuB,qBAAqB;AAC7D,SAEEC,yBAAyB,QACpB,qBAAqB;AAI5B;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CACvCC,UAAkB,EAClBC,QAAkB,EAClBC,SAA0B,EAC1BC,eAAqC,EAC7B;EAAA,IAAAC,OAAA,EAAAC,gBAAA;EACR;EACA;EACAT,uBAAuB,CAACM,SAAS,CAAC;EAElC,IAAII,OAAO,GAAGN,UAAU;;EAExB;EACA,MAAMO,YAAY,GAAGA,CACnBC,WAAmB,EACnBC,KAAoB,EACpBC,SAAqC,EACrCC,QAAgB,GAAGV,QAAQ,KAAKJ,QAAQ,CAACe,OAAO,GAAG,MAAM,GAAG,KAAK,KAC9D;IACH,IAAIH,KAAK,KAAKI,SAAS,IAAIJ,KAAK,KAAK,IAAI,EAAE;MACzCH,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAACN,WAAW,EAAEE,SAAS,CAACD,KAAK,CAAC,CAAC;IAC1D,CAAC,MAAM;MACLH,OAAO,GAAGA,OAAO,CAACQ,OAAO,CAACN,WAAW,EAAEG,QAAQ,CAAC;IAClD;EACF,CAAC;;EAED;EACA,MAAMI,aAAa,GAAGpB,gBAAgB,CAAC,CAAC;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,gBAAA,uBAAfA,gBAAA,CAAiBqB,IAAI,CAAC,CAAC,KAAIb,SAAS,EACnCK,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDZ,OAAO,GAAGR,yBAAyB,CAACQ,OAAO,EAAEL,QAAQ,EAAEE,eAAe,CAAC;EAEvE,OAAOG,OAAO;AAChB","ignoreList":[]}
@@ -9,8 +9,8 @@ function withCustomerIOPlugin(config, props) {
9
9
  }
10
10
 
11
11
  // Apply platform specific modifications
12
- config = withCIOIos(config, props.config, props.ios);
13
- config = withCIOAndroid(config, props.config, props.android);
12
+ config = withCIOIos(config, props.config, props.ios, props.location);
13
+ config = withCIOAndroid(config, props.config, props.android, props.location);
14
14
  return config;
15
15
  }
16
16
  export default withCustomerIOPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withCustomerIOPlugin","config","props","Error","ios","android"],"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 { CustomerIOPluginOptions } from './types/cio-types';\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);\n config = withCIOAndroid(config, props.config, props.android);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAG7C;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACH,uBAAuB,CAACG,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,CAAC;EACpDH,MAAM,GAAGJ,cAAc,CAACI,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAE5D,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}
1
+ {"version":3,"names":["withCIOAndroid","isExpoVersion53OrHigher","withCIOIos","withCustomerIOPlugin","config","props","Error","ios","location","android"],"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,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,uBAAuB,QAAQ,aAAa;AACrD,SAASC,UAAU,QAAQ,kBAAkB;AAS7C;AACA,SAASC,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAACH,uBAAuB,CAACG,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIE,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACE,GAAG,EAAEF,KAAK,CAACG,QAAQ,CAAC;EACpEJ,MAAM,GAAGJ,cAAc,CAACI,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,OAAO,EAAEJ,KAAK,CAACG,QAAQ,CAAC;EAE5E,OAAOJ,MAAM;AACf;AAEA,eAAeD,oBAAoB","ignoreList":[]}