customerio-expo-plugin 1.0.0-alpha.1 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/lib/commonjs/analytics/injectAnalytics.js +31 -0
  2. package/lib/commonjs/analytics/injectAnalytics.js.map +1 -0
  3. package/lib/commonjs/android/withAppGoogleServices.js +7 -1
  4. package/lib/commonjs/android/withAppGoogleServices.js.map +1 -1
  5. package/lib/commonjs/android/withGistMavenRepository.js +6 -1
  6. package/lib/commonjs/android/withGistMavenRepository.js.map +1 -1
  7. package/lib/commonjs/android/withGoogleServicesJSON.js +10 -6
  8. package/lib/commonjs/android/withGoogleServicesJSON.js.map +1 -1
  9. package/lib/commonjs/android/withProjectGoogleServices.js +5 -1
  10. package/lib/commonjs/android/withProjectGoogleServices.js.map +1 -1
  11. package/lib/commonjs/helpers/constants/android.js +4 -2
  12. package/lib/commonjs/helpers/constants/android.js.map +1 -1
  13. package/lib/commonjs/helpers/constants/ios.js +5 -3
  14. package/lib/commonjs/helpers/constants/ios.js.map +1 -1
  15. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  16. package/lib/commonjs/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  17. package/lib/{module/helpers/native-files/ios/CIONotificationService.m → commonjs/helpers/native-files/ios/NotificationService.m} +2 -6
  18. package/lib/{module/helpers/native-files/ios/CIONotificationService.swift → commonjs/helpers/native-files/ios/NotificationService.swift} +0 -2
  19. package/lib/commonjs/helpers/native-files/ios/PushNotification.swift +1 -10
  20. package/lib/commonjs/helpers/utils/fileManagement.js +32 -0
  21. package/lib/commonjs/helpers/utils/fileManagement.js.map +1 -1
  22. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +12 -7
  23. package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  24. package/lib/commonjs/index.js +8 -2
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/ios/withAppDelegateModifications.js +27 -18
  27. package/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
  28. package/lib/commonjs/ios/withAppDelegateXcodeProject.js +15 -32
  29. package/lib/commonjs/ios/withAppDelegateXcodeProject.js.map +1 -1
  30. package/lib/commonjs/ios/withCIOIos.js +8 -3
  31. package/lib/commonjs/ios/withCIOIos.js.map +1 -1
  32. package/lib/commonjs/ios/withNotificationsXcodeProject.js +17 -16
  33. package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
  34. package/lib/commonjs/types/cio-types.js +0 -13
  35. package/lib/commonjs/types/cio-types.js.map +1 -1
  36. package/lib/commonjs/version.js +9 -0
  37. package/lib/commonjs/version.js.map +1 -0
  38. package/lib/module/analytics/injectAnalytics.js +24 -0
  39. package/lib/module/analytics/injectAnalytics.js.map +1 -0
  40. package/lib/module/android/withAppGoogleServices.js +7 -1
  41. package/lib/module/android/withAppGoogleServices.js.map +1 -1
  42. package/lib/module/android/withGistMavenRepository.js +7 -2
  43. package/lib/module/android/withGistMavenRepository.js.map +1 -1
  44. package/lib/module/android/withGoogleServicesJSON.js +10 -6
  45. package/lib/module/android/withGoogleServicesJSON.js.map +1 -1
  46. package/lib/module/android/withProjectGoogleServices.js +5 -1
  47. package/lib/module/android/withProjectGoogleServices.js.map +1 -1
  48. package/lib/module/helpers/constants/android.js +2 -1
  49. package/lib/module/helpers/constants/android.js.map +1 -1
  50. package/lib/module/helpers/constants/ios.js +3 -2
  51. package/lib/module/helpers/constants/ios.js.map +1 -1
  52. package/lib/module/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  53. package/lib/module/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  54. package/{src/helpers/native-files/ios/CIONotificationService.m → lib/module/helpers/native-files/ios/NotificationService.m} +2 -6
  55. package/{src/helpers/native-files/ios/CIONotificationService.swift → lib/module/helpers/native-files/ios/NotificationService.swift} +0 -2
  56. package/lib/module/helpers/native-files/ios/PushNotification.swift +1 -10
  57. package/lib/module/helpers/utils/fileManagement.js +33 -1
  58. package/lib/module/helpers/utils/fileManagement.js.map +1 -1
  59. package/lib/module/helpers/utils/injectCIOPodfileCode.js +13 -8
  60. package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
  61. package/lib/module/index.js +8 -2
  62. package/lib/module/index.js.map +1 -1
  63. package/lib/module/ios/withAppDelegateModifications.js +27 -18
  64. package/lib/module/ios/withAppDelegateModifications.js.map +1 -1
  65. package/lib/module/ios/withAppDelegateXcodeProject.js +15 -32
  66. package/lib/module/ios/withAppDelegateXcodeProject.js.map +1 -1
  67. package/lib/module/ios/withCIOIos.js +8 -3
  68. package/lib/module/ios/withCIOIos.js.map +1 -1
  69. package/lib/module/ios/withNotificationsXcodeProject.js +17 -16
  70. package/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
  71. package/lib/module/types/cio-types.js +0 -8
  72. package/lib/module/types/cio-types.js.map +1 -1
  73. package/lib/module/version.js +2 -0
  74. package/lib/module/version.js.map +1 -0
  75. package/lib/typescript/analytics/injectAnalytics.d.ts +3 -0
  76. package/lib/typescript/helpers/constants/android.d.ts +1 -0
  77. package/lib/typescript/helpers/constants/ios.d.ts +2 -1
  78. package/lib/typescript/helpers/utils/fileManagement.d.ts +7 -0
  79. package/lib/typescript/index.d.ts +2 -2
  80. package/lib/typescript/types/cio-types.d.ts +7 -4
  81. package/lib/typescript/version.d.ts +1 -0
  82. package/package.json +3 -2
  83. package/src/analytics/injectAnalytics.ts +36 -0
  84. package/src/android/withAppGoogleServices.ts +11 -4
  85. package/src/android/withGistMavenRepository.ts +11 -4
  86. package/src/android/withGoogleServicesJSON.ts +17 -11
  87. package/src/android/withProjectGoogleServices.ts +9 -4
  88. package/src/helpers/constants/android.ts +3 -1
  89. package/src/helpers/constants/ios.ts +3 -3
  90. package/src/helpers/native-files/ios/{CIONotificationService-Info.plist → NotificationService-Info.plist} +2 -2
  91. package/src/helpers/native-files/ios/{CIONotificationService.h → NotificationService.h} +0 -0
  92. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.m → src/helpers/native-files/ios/NotificationService.m} +2 -6
  93. package/{lib/commonjs/helpers/native-files/ios/CIONotificationService.swift → src/helpers/native-files/ios/NotificationService.swift} +0 -2
  94. package/src/helpers/native-files/ios/PushNotification.swift +1 -10
  95. package/src/helpers/utils/fileManagement.ts +49 -1
  96. package/src/helpers/utils/injectCIOPodfileCode.ts +23 -17
  97. package/src/index.ts +12 -7
  98. package/src/ios/withAppDelegateModifications.ts +39 -23
  99. package/src/ios/withAppDelegateXcodeProject.ts +19 -40
  100. package/src/ios/withCIOIos.ts +9 -3
  101. package/src/ios/withNotificationsXcodeProject.ts +24 -18
  102. package/src/types/cio-types.ts +7 -4
  103. package/src/version.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n)*repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,6BAA6B,GACxC,4CAA4C;AAE9C,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF"}
1
+ {"version":3,"names":["CIO_PROJECT_BUILDSCRIPTS_REGEX","CIO_APP_APPLY_REGEX","CIO_GIST_MAVEN_REGEX","CIO_PROJECT_ALLPROJECTS_REGEX","CIO_PROJECT_GIST_MAVEN_SNIPPET","CIO_APP_GOOGLE_SNIPPET","CIO_PROJECT_GOOGLE_SNIPPET"],"sources":["android.ts"],"sourcesContent":["export const CIO_PROJECT_BUILDSCRIPTS_REGEX =\n /(buildscript\\s*\\{(.|\\n)*dependencies\\s*\\{)/;\nexport const CIO_APP_APPLY_REGEX = /(apply plugin: \"com.android.application\")/;\nexport const CIO_GIST_MAVEN_REGEX =\n /maven { url \"https:\\/\\/maven.gist.build\" }/;\nexport const CIO_PROJECT_ALLPROJECTS_REGEX =\n /(allprojects\\s*\\{(.|\\n){1,500}repositories\\s*\\{)/;\n\nexport const CIO_PROJECT_GIST_MAVEN_SNIPPET =\n ' maven { url \"https://maven.gist.build\" }';\nexport const CIO_APP_GOOGLE_SNIPPET =\n 'apply plugin: \"com.google.gms.google-services\" // Google Services plugin';\nexport const CIO_PROJECT_GOOGLE_SNIPPET =\n ' classpath \"com.google.gms:google-services:4.3.13\" // Google Services plugin';\n"],"mappings":"AAAA,OAAO,MAAMA,8BAA8B,GACzC,4CAA4C;AAC9C,OAAO,MAAMC,mBAAmB,GAAG,2CAA2C;AAC9E,OAAO,MAAMC,oBAAoB,GAC/B,4CAA4C;AAC9C,OAAO,MAAMC,6BAA6B,GACxC,kDAAkD;AAEpD,OAAO,MAAMC,8BAA8B,GACzC,kDAAkD;AACpD,OAAO,MAAMC,sBAAsB,GACjC,2EAA2E;AAC7E,OAAO,MAAMC,0BAA0B,GACrC,sFAAsF"}
@@ -1,7 +1,8 @@
1
1
  export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;
2
2
  export const IOS_DEPLOYMENT_TARGET = '13.0';
3
3
  export const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;
4
- export const CIO_PODFILE_NOTIFICATION_REGEX = /target 'CIONotificationService' do/;
4
+ export const CIO_CIO_TARGET_REGEX = /cio_target_names/;
5
+ export const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;
5
6
  export const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
6
7
  export const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;
7
8
  export const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;
@@ -15,7 +16,7 @@ export const CIO_APPDELEGATEHEADER_REGEX = /@interface AppDelegate : EXAppDelega
15
16
  export const DEFAULT_BUNDLE_VERSION = '1';
16
17
  export const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';
17
18
  export const CIO_TARGET_NAME = 'CustomerIOSDK';
18
- export const CIO_NOTIFICATION_TARGET_NAME = 'CIONotificationService';
19
+ export const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';
19
20
  export const CIO_APPDELEGATEHEADER_SNIPPET = `
20
21
  #import <UserNotifications/UserNotifications.h>
21
22
 
@@ -1 +1 @@
1
- {"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_PODFILE_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX =\n /target 'CIONotificationService' do/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'CIONotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\n// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method\n// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'\nend`;\nexport const CIO_PODFILE_SNIPPET = `\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;\nexport const CIO_PODFILE_TARGET_NAMES_SNIPPET = `\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]`;\nexport const CIO_PODFILE_POST_INSTALL_SNIPPET = `\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end`;\nexport const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend`;\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAC7G,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,iBAAiB,GAAG,iBAAiB;AAClD,OAAO,MAAMC,8BAA8B,GACzC,oCAAoC;AACtC,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,8BAA8B,GAAG,+BAA+B;AAC7E,OAAO,MAAMC,kCAAkC,GAC7C,gOAAgO;AAElO,OAAO,MAAMC,0DAA0D,GACrE,kGAAkG;AAEpG,OAAO,MAAMC,8DAA8D,GACzE,wJAAwJ;AAE1J,OAAO,MAAMC,0DAA0D,GACrE,wGAAwG;AAE1G,OAAO,MAAMC,gCAAgC,GAC3C,mCAAmC;AAErC,OAAO,MAAMC,2BAA2B,GACtC,mEAAmE;AACrE,OAAO,MAAMC,sBAAsB,GAAG,GAAG;AACzC,OAAO,MAAMC,4BAA4B,GAAG,KAAK;AACjD,OAAO,MAAMC,eAAe,GAAG,eAAe;AAC9C,OAAO,MAAMC,4BAA4B,GAAG,wBAAwB;AACpE,OAAO,MAAMC,6BAA6B,GAAI;AAC9C;AACA;AACA;AACA,CAAC;AAED,OAAO,MAAMC,8CAA8C,GAAI;AAC/D;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;AAED,OAAO,MAAMC,4DAA4D,GAAI;AAC7E;AACA,CAAC;;AAED;AACA;AACA,OAAO,MAAMC,2CAA2C,GAAI;AAC5D;AACA;AACA,CAAC;;AAED;AACA,OAAO,MAAMC,iDAAiD,GAAI;AAClE;AACA;AACA,EAAE;;AAEF;AACA,OAAO,MAAMC,0CAA0C,GAAI;AAC3D;AACA;AACA;AACA,EAAE;AACF,OAAO,MAAMC,gCAAgC,GAAI;AACjD,UAAUR,4BAA6B;AACvC;AACA,IAAI;AACJ,OAAO,MAAMS,mBAAmB,GAAI;AACpC;AACA;AACA,wDAAwD;AACxD,OAAO,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ,OAAO,MAAMC,gCAAgC,GAAI;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ;AACR,OAAO,MAAMC,yCAAyC,GAAI;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI"}
1
+ {"version":3,"names":["LOCAL_PATH_TO_CIO_NSE_FILES","IOS_DEPLOYMENT_TARGET","CIO_PODFILE_REGEX","CIO_CIO_TARGET_REGEX","CIO_PODFILE_NOTIFICATION_REGEX","GROUP_IDENTIFIER_TEMPLATE_REGEX","BUNDLE_SHORT_VERSION_TEMPLATE_REGEX","BUNDLE_VERSION_TEMPLATE_REGEX","CIO_PODFILE_POST_INSTALL_REGEX","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","DEFAULT_BUNDLE_VERSION","DEFAULT_BUNDLE_SHORT_VERSION","CIO_TARGET_NAME","CIO_NOTIFICATION_TARGET_NAME","CIO_APPDELEGATEHEADER_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_SNIPPET","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET"],"sources":["ios.ts"],"sourcesContent":["export const LOCAL_PATH_TO_CIO_NSE_FILES = `node_modules/customerio-expo-plugin/src/helpers/native-files/ios`;\nexport const IOS_DEPLOYMENT_TARGET = '13.0';\nexport const CIO_PODFILE_REGEX = /pod 'RCT-Folly'/;\nexport const CIO_CIO_TARGET_REGEX = /cio_target_names/;\nexport const CIO_PODFILE_NOTIFICATION_REGEX = /target 'NotificationService' do/;\nexport const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;\nexport const BUNDLE_SHORT_VERSION_TEMPLATE_REGEX = /{{BUNDLE_SHORT_VERSION}}/gm;\nexport const BUNDLE_VERSION_TEMPLATE_REGEX = /{{BUNDLE_VERSION}}/gm;\nexport const CIO_PODFILE_POST_INSTALL_REGEX = /post_install do \\|installer\\|/;\nexport const CIO_DIDFINISHLAUNCHINGMETHOD_REGEX =\n /(- \\(BOOL\\)application:\\(UIApplication \\*\\)application didFinishLaunchingWithOptions:\\(NSDictionary \\*\\)launchOptions(\\s|\\n)*?\\{)((.|\\n)*)\\[super(\\s)application:application(\\s)didFinishLaunchingWithOptions:launchOptions\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX =\n /return \\[super application:application didFailToRegisterForRemoteNotificationsWithError:error\\];/;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX =\n /(- \\(void\\)application:\\(UIApplication \\*\\)application didFailToRegisterForRemoteNotificationsWithError:\\(NSError \\*\\)error(\\s|\\n)*?\\{)(.|\\n){2}.*\\n\\}/;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX =\n /return \\[super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken\\];/;\n\nexport const CIO_APPDELEGATEDECLARATION_REGEX =\n /@implementation AppDelegate(.|\\n)/;\n\nexport const CIO_APPDELEGATEHEADER_REGEX =\n /@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate>/;\nexport const DEFAULT_BUNDLE_VERSION = '1';\nexport const DEFAULT_BUNDLE_SHORT_VERSION = '1.0';\nexport const CIO_TARGET_NAME = 'CustomerIOSDK';\nexport const CIO_NOTIFICATION_TARGET_NAME = 'NotificationService';\nexport const CIO_APPDELEGATEHEADER_SNIPPET = `\n#import <UserNotifications/UserNotifications.h>\n\n@interface AppDelegate : EXAppDelegateWrapper <RCTBridgeDelegate, UNUserNotificationCenterDelegate>\n`;\n\nexport const CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET = `\nCIOAppPushNotificationsHandler* pnHandlerObj = [[CIOAppPushNotificationsHandler alloc] init];\n`;\n\nexport const CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET = `\n [pnHandlerObj application:application error:error];\n`;\n\nexport const CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET = `\n return [pnHandlerObj application:application deviceToken:deviceToken];\n`;\n\n// Configure Customerio push notifications SDK by adding to application:didFinishLaunchingWithOptions: delegate method\n// From Braze docs: https://www.customer.io/docs/sdk/react-native/push/#obj-c-push\nexport const CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET = `\n // Register for push notifications\n [pnHandlerObj registerPushNotification:self];\n`;\n\n// Enable push handling - notification response\nexport const CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET = `\n- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler {\n [pnHandlerObj userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];\n}`;\n\n// Foreground push handling\nexport const CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET = `\n// show push when the app is in foreground\n- (void)userNotificationCenter:(UNUserNotificationCenter* )center willPresentNotification:(UNNotification* )notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {\n completionHandler( UNNotificationPresentationOptionAlert + UNNotificationPresentationOptionSound);\n}`;\nexport const CIO_PODFILE_NOTIFICATION_SNIPPET = `\ntarget '${CIO_NOTIFICATION_TARGET_NAME}' do\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'\nend`;\nexport const CIO_PODFILE_SNIPPET = `\n pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'\n pod 'boost', :podspec => '../node_modules/react-native/third-party-podspecs/boost.podspec'\n pod 'CustomerIO/MessagingPushAPN', '~> 1.2.0-alpha.3'`;\nexport const CIO_PODFILE_TARGET_NAMES_SNIPPET = `\n cio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n ]`;\nexport const CIO_PODFILE_POST_INSTALL_SNIPPET = `\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end`;\nexport const CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET = `\ncio_target_names = [\n 'CustomerIOTracking',\n 'CustomerIOCommon',\n 'CustomerIOMessagingPushAPN',\n 'CustomerIOMessagingPush'\n]\n\npost_install do |installer|\n\n installer.pods_project.targets.each do |target|\n if cio_target_names.include? target.name\n puts \"Modifying target #{target.name}\"\n\n target.build_configurations.each do |config|\n puts \"Setting build config settings for #{target.name}\"\n config.build_settings['APPLICATION_EXTENSION_API_ONLY'] ||= 'NO'\n end\n end\n end\n react_native_post_install(installer)\n __apply_Xcode_12_5_M1_post_install_workaround(installer)\nend`;\n"],"mappings":"AAAA,OAAO,MAAMA,2BAA2B,GAAI,kEAAiE;AAC7G,OAAO,MAAMC,qBAAqB,GAAG,MAAM;AAC3C,OAAO,MAAMC,iBAAiB,GAAG,iBAAiB;AAClD,OAAO,MAAMC,oBAAoB,GAAG,kBAAkB;AACtD,OAAO,MAAMC,8BAA8B,GAAG,iCAAiC;AAC/E,OAAO,MAAMC,+BAA+B,GAAG,wBAAwB;AACvE,OAAO,MAAMC,mCAAmC,GAAG,4BAA4B;AAC/E,OAAO,MAAMC,6BAA6B,GAAG,sBAAsB;AACnE,OAAO,MAAMC,8BAA8B,GAAG,+BAA+B;AAC7E,OAAO,MAAMC,kCAAkC,GAC7C,gOAAgO;AAElO,OAAO,MAAMC,0DAA0D,GACrE,kG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key>
10
10
  <string>$(DEVELOPMENT_LANGUAGE)</string>
11
11
  <key>CFBundleDisplayName</key>
12
- <string>CIONotificationServiceExtension</string>
12
+ <string>NotificationServiceExtension</string>
13
13
  <key>CFBundleExecutable</key>
14
14
  <string>$(EXECUTABLE_NAME)</string>
15
15
  <key>CFBundleIdentifier</key>
@@ -25,7 +25,7 @@
25
25
  <key>NSExtensionPointIdentifier</key>
26
26
  <string>com.apple.usernotifications.service</string>
27
27
  <key>NSExtensionPrincipalClass</key>
28
- <string>CIONotificationService</string>
28
+ <string>NotificationService</string>
29
29
  </dict>
30
30
  </dict>
31
31
  </plist>
@@ -1,8 +1,6 @@
1
1
 
2
- #import "CIONotificationService.h"
3
- // MARK: - CIO-TECH-ASSISTANCE
4
- // Import "Your-target-name-Swift.h" file
5
- #import "CIONotificationService-Swift.h"
2
+ #import "NotificationService.h"
3
+ #import "NotificationService-Swift.h"
6
4
 
7
5
  @interface NotificationService ()
8
6
 
@@ -14,7 +12,6 @@
14
12
  @implementation NotificationService
15
13
 
16
14
  - (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
17
- // MARK: - CIO-TECH-ASSISTANCE
18
15
  NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
19
16
  [cioManagerObj didReceive:request withContentHandler:contentHandler];
20
17
  }
@@ -22,7 +19,6 @@
22
19
  - (void)serviceExtensionTimeWillExpire {
23
20
  // Called just before the extension will be terminated by the system.
24
21
  // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
25
- // MARK: - CIO-TECH-ASSISTANCE
26
22
  NotificationServiceCioManager* cioManagerObj = [[NotificationServiceCioManager alloc] init];
27
23
  [cioManagerObj serviceExtensionTimeWillExpire];
28
24
  }
@@ -2,8 +2,6 @@ import Foundation
2
2
  import UserNotifications
3
3
  import CioMessagingPush
4
4
 
5
- // MARK: - CIO-TECH-ASSISTANCE
6
- // This is another example of handling ObjC calls for Swift CustomerIO SDK
7
5
  @objc
8
6
  public class NotificationServiceCioManager : NSObject {
9
7
 
@@ -1,10 +1,3 @@
1
- //
2
- // PushNotification.swift
3
- // testandroidapp
4
- //
5
- // Created by Segun Xtreem on 10/09/2022.
6
- //
7
-
8
1
  import Foundation
9
2
  import CioMessagingPushAPN
10
3
  import CioTracking
@@ -16,12 +9,11 @@ public class CIOAppPushNotificationsHandler : NSObject {
16
9
 
17
10
  public override init() {}
18
11
 
19
- // MARK: - ObjCNEW
20
12
  @objc(registerPushNotification:)
21
13
  public func registerPushNotification(withNotificationDelegate notificationDelegate: UNUserNotificationCenterDelegate) {
22
14
 
23
15
  let center = UNUserNotificationCenter.current()
24
- center.delegate = notificationDelegate // MARK: - ObjCNEW
16
+ center.delegate = notificationDelegate
25
17
  center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
26
18
  if error == nil{
27
19
  DispatchQueue.main.async {
@@ -41,7 +33,6 @@ public class CIOAppPushNotificationsHandler : NSObject {
41
33
  MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
42
34
  }
43
35
 
44
- // MARK: - ObjCNEW
45
36
  @objc(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)
46
37
  public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
47
38
  let handled = MessagingPush.shared.userNotificationCenter(center, didReceive: response,
@@ -1,4 +1,4 @@
1
- import { readFile, writeFile, appendFile } from 'fs';
1
+ import { readFile, writeFile, appendFile, existsSync, copyFileSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
2
2
  export class FileManagement {
3
3
  static async read(path) {
4
4
  return new Promise((resolve, reject) => {
@@ -33,5 +33,37 @@ export class FileManagement {
33
33
  });
34
34
  });
35
35
  }
36
+ static exists(path) {
37
+ return existsSync(path);
38
+ }
39
+ static copyFile(src, dest) {
40
+ try {
41
+ copyFileSync(src, dest);
42
+ } catch (err) {
43
+ console.log(`Error copying file from ${src} to ${dest}: `, err);
44
+ }
45
+ }
46
+ static mkdir(path, options) {
47
+ try {
48
+ mkdirSync(path, options);
49
+ } catch (err) {
50
+ console.log(`Error creating directory ${path}: `, err);
51
+ }
52
+ }
53
+ static writeFile(path, data) {
54
+ try {
55
+ writeFileSync(path, data);
56
+ } catch (err) {
57
+ console.log(`Error writing to file ${path}: `, err);
58
+ }
59
+ }
60
+ static readFile(path) {
61
+ try {
62
+ return readFileSync(path, 'utf-8');
63
+ } catch (err) {
64
+ console.log(`Error reading file ${path}: `, err);
65
+ }
66
+ return '';
67
+ }
36
68
  }
37
69
  //# sourceMappingURL=fileManagement.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["readFile","writeFile","appendFile","FileManagement","read","path","Promise","resolve","reject","err","data","write","contents","append"],"sources":["fileManagement.ts"],"sourcesContent":["import { readFile, writeFile, appendFile } from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n}\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,IAAI;AAEpD,OAAO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAI,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9CR,QAAQ,CAACK,IAAI,EAAE,MAAM,EAAE,CAACI,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBF,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,CAACG,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAK,CAACN,IAAY,EAAEO,QAAgB,EAAiB;IAChE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5CP,SAAS,CAACI,IAAI,EAAEO,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QACzC,IAAIA,GAAG,EAAE;UACPD,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaM,MAAM,CAACR,IAAY,EAAEO,QAAgB,EAAiB;IACjE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC5CN,UAAU,CAACG,IAAI,EAAEO,QAAQ,EAAE,MAAM,EAAGH,GAAG,IAAK;QAC1C,IAAIA,GAAG,EAAE;UACPD,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,EAAE;MACX,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF"}
1
+ {"version":3,"names":["readFile","writeFile","appendFile","existsSync","copyFileSync","mkdirSync","writeFileSync","readFileSync","FileManagement","read","path","Promise","resolve","reject","err","data","write","contents","append","exists","copyFile","src","dest","console","log","mkdir","options"],"sources":["fileManagement.ts"],"sourcesContent":["import {\n readFile,\n writeFile,\n appendFile,\n existsSync,\n copyFileSync,\n mkdirSync,\n writeFileSync,\n readFileSync,\n MakeDirectoryOptions,\n} from 'fs';\n\nexport class FileManagement {\n static async read(path: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n readFile(path, 'utf8', (err, data) => {\n if (err || !data) {\n reject(err);\n return;\n }\n resolve(data);\n });\n });\n }\n\n static async write(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n writeFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static async append(path: string, contents: string): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n appendFile(path, contents, 'utf8', (err) => {\n if (err) {\n reject(err);\n return;\n }\n resolve();\n });\n });\n }\n\n static exists(path: string) {\n return existsSync(path);\n }\n\n static copyFile(src: string, dest: string) {\n try {\n copyFileSync(src, dest);\n } catch (err) {\n console.log(`Error copying file from ${src} to ${dest}: `, err);\n }\n }\n\n static mkdir(path: string, options: MakeDirectoryOptions) {\n try {\n mkdirSync(path, options);\n } catch (err) {\n console.log(`Error creating directory ${path}: `, err);\n }\n }\n\n static writeFile(path: string, data: string) {\n try {\n writeFileSync(path, data);\n } catch (err) {\n console.log(`Error writing to file ${path}: `, err);\n }\n }\n\n static readFile(path: string) {\n try {\n return readFileSync(path, 'utf-8');\n } catch (err) {\n console.log(`Error reading file ${path}: `, err);\n }\n\n return '';\n }\n}\n"],"mappings":"AAAA,SACEA,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,UAAU,EACVC,YAAY,EACZC,SAAS,EACTC,aAAa,EACbC,YAAY,QAEP,IAAI;AAEX,OAAO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAI,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,OAAO,EAAEC,MAAM,KAAK;MAC9Cb,QAAQ,CAACU,IAAI,EAAE,MAAM,EAAE,CAACI,GAAG,EAAEC,IAAI,KAAK;QACpC,IAAID,GAAG,IAAI,CAACC,IAAI,EAAE;UAChBF,MAAM,CAACC,GAAG,CAAC;UACX;QACF;QACAF,OAAO,CAACG,IAAI,CAAC;MACf,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;EAEA,aAAaC,KAAK,CAACN,IAAY,EAAEO,QAAgB,EAAiB;IAChE,OAAO,IAAIN,OAAO,CAAO,CAACC,OAAO,EAAEC,M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AO,CAACC,GAAG,CAAE,yBAAwBd,IAAK,IAAG,EAAEI,GAAG,CAAC;IACrD;EACF;EAEA,OAAOd,QAAQ,CAACU,IAAY,EAAE;IAC5B,IAAI;MACF,OAAOH,YAAY,CAACG,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOI,GAAG,EAAE;MACZS,OAAO,CAACC,GAAG,CAAE,sBAAqBd,IAAK,IAAG,EAAEI,GAAG,CAAC;IAClD;IAEA,OAAO,EAAE;EACX;AACF"}
@@ -1,18 +1,23 @@
1
- import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET, CIO_PODFILE_POST_INSTALL_REGEX, CIO_PODFILE_TARGET_NAMES_SNIPPET, CIO_PODFILE_POST_INSTALL_SNIPPET, CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET, CIO_PODFILE_NOTIFICATION_SNIPPET, CIO_PODFILE_NOTIFICATION_REGEX } from '../constants/ios';
1
+ import { CIO_PODFILE_REGEX, CIO_PODFILE_SNIPPET, CIO_PODFILE_POST_INSTALL_REGEX, CIO_PODFILE_TARGET_NAMES_SNIPPET, CIO_PODFILE_POST_INSTALL_SNIPPET, CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET, CIO_PODFILE_NOTIFICATION_SNIPPET, CIO_PODFILE_NOTIFICATION_REGEX, CIO_CIO_TARGET_REGEX } from '../constants/ios';
2
2
  import { FileManagement } from './fileManagement';
3
3
  export async function injectCIOPodfileCode(iosPath) {
4
4
  const filename = `${iosPath}/Podfile`;
5
5
  const podfile = await FileManagement.read(filename);
6
6
  const matches = podfile.match(CIO_PODFILE_REGEX);
7
- const lines = podfile.split('\n');
8
- const index = lines.findIndex(line => CIO_PODFILE_POST_INSTALL_REGEX.test(line));
9
- let content = lines;
10
- if (index > -1) {
11
- content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '', CIO_PODFILE_TARGET_NAMES_SNIPPET, ...lines.slice(index - 1, index + 1), CIO_PODFILE_POST_INSTALL_SNIPPET, ...lines.slice(index + 1)];
7
+ const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);
8
+ if (!targetMatch) {
9
+ const lines = podfile.split('\n');
10
+ const index = lines.findIndex(line => CIO_PODFILE_POST_INSTALL_REGEX.test(line));
11
+ let content = lines;
12
+ if (index > -1) {
13
+ content = [...lines.slice(0, index - 1), !matches ? CIO_PODFILE_SNIPPET : '', CIO_PODFILE_TARGET_NAMES_SNIPPET, ...lines.slice(index - 1, index + 1), CIO_PODFILE_POST_INSTALL_SNIPPET, ...lines.slice(index + 1)];
14
+ } else {
15
+ content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
16
+ }
17
+ FileManagement.write(filename, content.join('\n'));
12
18
  } else {
13
- content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);
19
+ console.log('Customerio Podfile snippets already exists. Skipping...');
14
20
  }
15
- FileManagement.write(filename, content.join('\n'));
16
21
  }
17
22
  export async function injectCIONotificationPodfileCode(iosPath) {
18
23
  const filename = `${iosPath}/Podfile`;
@@ -1 +1 @@
1
- {"version":3,"names":["CIO_PODFILE_REGEX","CIO_PODFILE_SNIPPET","CIO_PODFILE_POST_INSTALL_REGEX","CIO_PODFILE_TARGET_NAMES_SNIPPET","CIO_PODFILE_POST_INSTALL_SNIPPET","CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","lines","split","index","findIndex","line","test","content","slice","push","write","join","injectCIONotificationPodfileCode","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_POST_INSTALL_REGEX,\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n ...lines.slice(index - 1, index + 1),\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n ...lines.slice(index + 1),\n ];\n } else {\n content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);\n }\n\n FileManagement.write(filename, content.join('\\n'));\n}\n\nexport async function injectCIONotificationPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_NOTIFICATION_REGEX);\n\n if (!matches) {\n FileManagement.append(filename, CIO_PODFILE_NOTIFICATION_SNIPPET);\n }\n}\n"],"mappings":"AAAA,SACEA,iBAAiB,EACjBC,mBAAmB,EACnBC,8BAA8B,EAC9BC,gCAAgC,EAChCC,gCAAgC,EAChCC,yCAAyC,EACzCC,gCAAgC,EAChCC,8BAA8B,QACzB,kBAAkB;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,OAAO,eAAeC,oBAAoB,CAACC,OAAe,EAAE;EAC1D,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACf,iBAAiB,CAAC;EAEhD,MAAMgB,K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FALLBACK_SNIPPET","CIO_PODFILE_NOTIFICATION_SNIPPET","CIO_PODFILE_NOTIFICATION_REGEX","CIO_CIO_TARGET_REGEX","FileManagement","injectCIOPodfileCode","iosPath","filename","podfile","read","matches","match","targetMatch","lines","split","index","findIndex","line","test","content","slice","push","write","join","console","log","injectCIONotificationPodfileCode","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import {\n CIO_PODFILE_REGEX,\n CIO_PODFILE_SNIPPET,\n CIO_PODFILE_POST_INSTALL_REGEX,\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET,\n CIO_PODFILE_NOTIFICATION_SNIPPET,\n CIO_PODFILE_NOTIFICATION_REGEX,\n CIO_CIO_TARGET_REGEX,\n} from '../constants/ios';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(CIO_PODFILE_REGEX);\n const targetMatch = podfile.match(CIO_CIO_TARGET_REGEX);\n\n if (!targetMatch) {\n const lines = podfile.split('\\n');\n const index = lines.findIndex((line) =>\n CIO_PODFILE_POST_INSTALL_REGEX.test(line)\n );\n let content: string[] = lines;\n if (index > -1) {\n content = [\n ...lines.slice(0, index - 1),\n !matches ? CIO_PODFILE_SNIPPET : '',\n CIO_PODFILE_TARGET_NAMES_SNIPPET,\n ...lines.slice(index - 1, index + 1),\n CIO_PODFILE_POST_INSTALL_SNIPPET,\n ...lines.slice(index + 1),\n ];\n } else {\n content.push(CIO_PODFILE_POST_INSTALL_FALLBACK_SNIPPET);\n }\n\n FileManagement.write(filename, content.join('\\n'));\n } else {\n console.log('Customerio Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(iosPath: string) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = pod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MACLI,OAAO,CAACE,IAAI,CAACrB,yCAAyC,CAAC;IACzD;IAEAI,cAAc,CAACkB,KAAK,CAACf,QAAQ,EAAEY,OAAO,CAACI,IAAI,CAAC,IAAI,CAAC,CAAC;EACpD,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEA,OAAO,eAAeC,gCAAgC,CAACpB,OAAe,EAAE;EACtE,MAAMC,QAAQ,GAAI,GAAED,OAAQ,UAAS;EACrC,MAAME,OAAO,GAAG,MAAMJ,cAAc,CAACK,IAAI,CAACF,QAAQ,CAAC;EACnD,MAAMG,OAAO,GAAGF,OAAO,CAACG,KAAK,CAACT,8BAA8B,CAAC;EAE7D,IAAI,CAACQ,OAAO,EAAE;IACZN,cAAc,CAACuB,MAAM,CAACpB,QAAQ,EAAEN,gCAAgC,CAAC;EACnE;AACF"}
@@ -1,9 +1,15 @@
1
+ import { withAnalytics } from './analytics/injectAnalytics';
1
2
  import { withCIOAndroid } from './android/withCIOAndroid';
2
3
  import { withCIOIos } from './ios/withCIOIos';
3
4
  // Entry point for config plugin
4
5
  function withCustomerIOPlugin(config, props) {
5
- config = withCIOIos(config, props);
6
- config = withCIOAndroid(config, props);
6
+ if (props.ios) {
7
+ config = withCIOIos(config, props.ios);
8
+ }
9
+ if (props.android) {
10
+ config = withCIOAndroid(config, props.android);
11
+ }
12
+ config = withAnalytics(config, props);
7
13
  return config;
8
14
  }
9
15
  export default withCustomerIOPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptionsIOS,\n CustomerIOPluginOptionsAndroid,\n} from './types/cio-types';\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS | CustomerIOPluginOptionsAndroid\n) {\n config = withCIOIos(config, props as CustomerIOPluginOptionsIOS);\n config = withCIOAndroid(config, props as CustomerIOPluginOptionsAndroid);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAM7C;AACA,SAASC,oBAAoB,CAC3BC,MAAkB,EAClBC,KAAkE,EAClE;EACAD,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAA+B;EAChED,MAAM,GAAGH,cAAc,CAACG,MAAM,EAAEC,KAAK,CAAmC;EAExE,OAAOD,MAAM;AACf;AAEA,eAAeD,oBAAoB"}
1
+ {"version":3,"names":["withAnalytics","withCIOAndroid","withCIOIos","withCustomerIOPlugin","config","props","ios","android"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withAnalytics } from './analytics/injectAnalytics';\nimport { withCIOAndroid } from './android/withCIOAndroid';\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 if (props.ios) {\n config = withCIOIos(config, props.ios);\n }\n\n if (props.android) {\n config = withCIOAndroid(config, props.android);\n }\n\n config = withAnalytics(config, props);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":"AAEA,SAASA,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,UAAU,QAAQ,kBAAkB;AAG7C;AACA,SAASC,oBAAoB,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAGF,UAAU,CAACE,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACE,OAAO,EAAE;IACjBH,MAAM,GAAGH,cAAc,CAACG,MAAM,EAAEC,KAAK,CAACE,OAAO,CAAC;EAChD;EAEAH,MAAM,GAAGJ,aAAa,CAACI,MAAM,EAAEC,KAAK,CAAC;EAErC,OAAOD,MAAM;AACf;AAEA,eAAeD,oBAAoB"}
@@ -4,15 +4,11 @@ import { CIO_APPDELEGATEDECLARATION_REGEX, CIO_APPDELEGATEHEADER_REGEX, CIO_APPD
4
4
  import { injectCodeByLineNumber, injectCodeByMultiLineRegex, injectCodeByMultiLineRegexAndReplaceLine } from '../helpers/utils/codeInjection';
5
5
  import { FileManagement } from '../helpers/utils/fileManagement';
6
6
  const pushCodeSnippets = [CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET, CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET];
7
- const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join w/ newlines and ensure a newline at the end.
7
+ const additionalMethodsForPushNotifications = `${pushCodeSnippets.join('\n')}\n`; // Join newlines and ensure a newline at the end.
8
8
 
9
- const addImport = stringContents => {
9
+ const addImport = (stringContents, appName) => {
10
10
  const importRegex = /^(#import .*)\n/gm;
11
- const addedImport = `
12
- // Add swift bridge imports
13
- #import <ExpoModulesCore-Swift.h>
14
- #import <testiosapp-Swift.h>
15
- `;
11
+ const addedImport = getImportSnippet(appName);
16
12
  const match = stringContents.match(importRegex);
17
13
  let endOfMatchIndex;
18
14
  if (!match || match.index === undefined) {
@@ -52,18 +48,31 @@ const addAppdelegateHeaderModification = stringContents => {
52
48
  export const withAppDelegateModifications = configOuter => {
53
49
  return withAppDelegate(configOuter, async config => {
54
50
  let stringContents = config.modResults.contents;
55
- const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
56
- let headerContent = await FileManagement.read(headerPath);
57
- headerContent = addAppdelegateHeaderModification(headerContent);
58
- FileManagement.write(headerPath, headerContent);
59
- stringContents = addImport(stringContents);
60
- stringContents = addNotificationHandlerDeclaration(stringContents);
61
- stringContents = addNotificationConfiguration(stringContents);
62
- stringContents = addAdditionalMethodsForPushNotifications(stringContents);
63
- stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
64
- stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
65
- config.modResults.contents = stringContents;
51
+ const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
52
+ const match = stringContents.match(regex);
53
+ if (!match) {
54
+ const headerPath = getAppDelegateHeaderFilePath(config.modRequest.projectRoot);
55
+ let headerContent = await FileManagement.read(headerPath);
56
+ headerContent = addAppdelegateHeaderModification(headerContent);
57
+ FileManagement.write(headerPath, headerContent);
58
+ stringContents = addImport(stringContents, config.modRequest.projectName);
59
+ stringContents = addNotificationHandlerDeclaration(stringContents);
60
+ stringContents = addNotificationConfiguration(stringContents);
61
+ stringContents = addAdditionalMethodsForPushNotifications(stringContents);
62
+ stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
63
+ stringContents = AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
64
+ config.modResults.contents = stringContents;
65
+ } else {
66
+ console.log('Customerio AppDelegate changes already exist. Skipping...');
67
+ }
66
68
  return config;
67
69
  });
68
70
  };
71
+ function getImportSnippet(appName) {
72
+ return `
73
+ // Add swift bridge imports
74
+ #import <ExpoModulesCore-Swift.h>
75
+ #import <${appName}-Swift.h>
76
+ `;
77
+ }
69
78
  //# sourceMappingURL=withAppDelegateModifications.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","importRegex","addedImport","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","AddDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","config","modResults","contents","headerPath","modRequest","projectRoot","headerContent","read","write"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join w/ newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <testiosapp-Swift.h>\n `;\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst AddDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(stringContents);\n stringContents = addNotificationHandlerDeclaration(stringContents);\n stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(string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3B,cAAc,CAAC6B,KAAK,CAACL,UAAU,EAAEG,aAAa,CAAC;IAE/CtB,cAAc,GAAGD,SAAS,CAACC,cAAc,CAAC;IAC1CA,cAAc,GAAGQ,iCAAiC,CAACR,cAAc,CAAC;IAClEA,cAAc,GAAGS,4BAA4B,CAACT,cAAc,CAAC;IAC7DA,cAAc,GAAGY,wCAAwC,CAACZ,cAAc,CAAC;IACzEA,cAAc,GACZU,mDAAmD,CAACV,cAAc,CAAC;IACrEA,cAAc,GACZW,mDAAmD,CAACX,cAAc,CAAC;IAErEgB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGlB,cAAc;IAC3C,OAAOgB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withAppDelegate","getAppDelegateHeaderFilePath","CIO_APPDELEGATEDECLARATION_REGEX","CIO_APPDELEGATEHEADER_REGEX","CIO_APPDELEGATEHEADER_SNIPPET","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET","injectCodeByLineNumber","injectCodeByMultiLineRegex","injectCodeByMultiLineRegexAndReplaceLine","FileManagement","pushCodeSnippets","additionalMethodsForPushNotifications","join","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","addNotificationHandlerDeclaration","addNotificationConfiguration","addDidFailToRegisterForRemoteNotificationsWithError","AddDidRegisterForRemoteNotificationsWithDeviceToken","addAdditionalMethodsForPushNotifications","addAppdelegateHeaderModification","withAppDelegateModifications","configOuter","config","modResults","contents","regex","RegExp","modRequest","projectName","headerPath","projectRoot","headerContent","read","write","console","log"],"sources":["withAppDelegateModifications.ts"],"sourcesContent":["import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins';\nimport { getAppDelegateHeaderFilePath } from '@expo/config-plugins/build/ios/Paths';\n\nimport {\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\n\nconst pushCodeSnippets = [\n CIO_DIDRECEIVENOTIFICATIONRESPONSEHANDLER_SNIPPET,\n CIO_WILLPRESENTNOTIFICATIONHANDLER_SNIPPET,\n];\n\nconst additionalMethodsForPushNotifications = `${pushCodeSnippets.join(\n '\\n'\n)}\\n`; // Join newlines and ensure a newline at the end.\n\nconst addImport = (stringContents: string, appName: string) => {\n const importRegex = /^(#import .*)\\n/gm;\n const addedImport = getImportSnippet(appName);\n\n const match = stringContents.match(importRegex);\n let endOfMatchIndex: number;\n if (!match || match.index === undefined) {\n // No imports found, just add to start of file:\n endOfMatchIndex = 0;\n } else {\n // Add after first import:\n endOfMatchIndex = match.index + match[0].length;\n }\n\n stringContents = injectCodeByLineNumber(\n stringContents,\n endOfMatchIndex,\n addedImport\n ).join('\\n');\n\n return stringContents;\n};\n\nconst addNotificationHandlerDeclaration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_APPDELEGATEDECLARATION_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addNotificationConfiguration = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addDidFailToRegisterForRemoteNotificationsWithError = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET\n );\n\n return stringContents;\n};\n\nconst AddDidRegisterForRemoteNotificationsWithDeviceToken = (\n stringContents: string\n) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addAdditionalMethodsForPushNotifications = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegex(\n stringContents,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERRORFULL_REGEX,\n additionalMethodsForPushNotifications\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByMultiLineRegexAndReplaceLine(\n stringContents,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_SNIPPET\n );\n\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<any> = (\n configOuter\n) => {\n return withAppDelegate(configOuter, async (config) => {\n let stringContents = config.modResults.contents;\n const regex = new RegExp(\n `#import <${config.modRequest.projectName}-Swift.h>`\n );\n const match = stringContents.match(regex);\n\n if (!match) {\n const headerPath = getAppDelegateHeaderFilePath(\n config.modRequest.projectRoot\n );\n let headerContent = await FileManagement.read(headerPath);\n headerContent = addAppdelegateHeaderModification(headerContent);\n FileManagement.write(headerPath, headerContent);\n\n stringContents = addImport(\n stringContents,\n config.modRequest.projectName as string\n );\n stringContents = addNotificationHandlerDeclaration(stringContents);\n stringContents = addNotificationConfiguration(stringContents);\n stringContents = addAdditionalMethodsForPushNotifications(stringContents);\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n AddDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n config.modResults.contents = stringContents;\n } else {\n console.log('Customerio AppDelegate changes already exist. Skipping...');\n }\n\n return config;\n });\n};\nfunction getImportSnippet(appName: string) {\n return `\n// Add swift bridge imports\n#import <ExpoModulesCore-Swift.h>\n#import <${appName}-Swift.h>\n `;\n}\n"],"mappings":"AAAA,SAAuBA,eAAe,QAAQ,sBAAsB;AACpE,SAASC,4BAA4B,QAAQ,sCAAsC;AAEnF,SACEC,gCAAgC,EAChCC,2BAA2B,EAC3BC,6BAA6B,EAC7BC,2CAA2C,EAC3CC,8DAA8D,EAC9DC,0DAA0D,EAC1DC,4DAA4D,EAC5DC,kCAAkC,EAClCC,iDAA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cAAc,GAAGD,SAAS,CACxBC,cAAc,EACdkB,MAAM,CAACK,UAAU,CAACC,WAAW,CAC9B;MACDxB,cAAc,GAAGU,iCAAiC,CAACV,cAAc,CAAC;MAClEA,cAAc,GAAGW,4BAA4B,CAACX,cAAc,CAAC;MAC7DA,cAAc,GAAGc,wCAAwC,CAACd,cAAc,CAAC;MACzEA,cAAc,GACZY,mDAAmD,CAACZ,cAAc,CAAC;MACrEA,cAAc,GACZa,mDAAmD,CAACb,cAAc,CAAC;MAErEkB,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGpB,cAAc;IAC7C,CAAC,MAAM;MACL8B,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOb,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AACD,SAASd,gBAAgB,CAACH,OAAe,EAAE;EACzC,OAAQ;AACV;AACA;AACA,WAAWA,OAAQ;AACnB,GAAG;AACH"}
@@ -1,8 +1,8 @@
1
1
  import { withXcodeProject } from '@expo/config-plugins';
2
- import fs from 'fs';
3
2
  import xcode from 'xcode';
4
3
  import { DEFAULT_BUNDLE_VERSION, LOCAL_PATH_TO_CIO_NSE_FILES } from '../helpers/constants/ios';
5
- const addNotificationServiceExtensionFile = async options => {
4
+ import { FileManagement } from './../helpers/utils/fileManagement';
5
+ const addNotificationSwiftFile = async options => {
6
6
  const {
7
7
  iosPath,
8
8
  appName
@@ -10,37 +10,20 @@ const addNotificationServiceExtensionFile = async options => {
10
10
  const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
11
11
  const xcodeProject = xcode.project(projPath);
12
12
  xcodeProject.parse(async function (err) {
13
+ const file = 'PushNotification.swift';
14
+ const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
13
15
  if (err) {
14
16
  throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);
15
17
  }
16
- fs.mkdirSync(`${iosPath}/${appName}`, {
17
- recursive: true
18
- });
19
- const file = 'PushNotification.swift';
20
- const getTargetFile = filename => `${iosPath}/${appName}/${filename}`;
21
- const targetFile = getTargetFile(file);
22
- fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
23
-
24
- // Create new PBXGroup for the extension
25
- const extGroup = xcodeProject.addPbxGroup([file], appName, appName);
26
-
27
- // Add the new PBXGroup to the top level group. This makes the
28
- // files / folder appear in the file explorer in Xcode.
29
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
30
- Object.keys(groups).forEach(key => {
31
- if (groups[key].name === undefined) {
32
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
33
- }
34
- });
35
-
36
- // WORK AROUND for codeProject.addTarget BUG
37
- // Xcode projects don't contain these if there is only one target
38
- // An upstream fix should be made to the code referenced in this link:
39
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
40
- const projObjects = xcodeProject.hash.project.objects;
41
- projObjects['PBXTargetDependency'] = projObjects['PBXTargetDependency'] || {};
42
- projObjects['PBXContainerItemProxy'] = projObjects['PBXTargetDependency'] || {};
43
- fs.writeFileSync(projPath, xcodeProject.writeSync());
18
+ if (!FileManagement.exists(getTargetFile(file))) {
19
+ FileManagement.mkdir(`${iosPath}/${appName}`, {
20
+ recursive: true
21
+ });
22
+ const targetFile = getTargetFile(file);
23
+ FileManagement.copyFile(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);
24
+ } else {
25
+ console.log(`${getTargetFile(file)} already exists. Skipping...`);
26
+ }
44
27
  });
45
28
  };
46
29
  export const withCioAppdelegateXcodeProject = (configOuter, props) => {
@@ -76,12 +59,12 @@ export const withCioAppdelegateXcodeProject = (configOuter, props) => {
76
59
  appleTeamId,
77
60
  bundleIdentifier,
78
61
  bundleShortVersion,
79
- bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,
62
+ bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,
80
63
  iosPath: platformProjectRoot,
81
64
  appName: projectName,
82
65
  iosDeploymentTarget
83
66
  };
84
- await addNotificationServiceExtensionFile(options);
67
+ await addNotificationSwiftFile(options);
85
68
  return config;
86
69
  });
87
70
  };
@@ -1 +1 @@
1
- {"version":3,"names":["withXcodeProject","fs","xcode","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","addNotificationServiceExtensionFile","options","iosPath","appName","projPath","xcodeProject","project","parse","err","Error","JSON","stringify","mkdirSync","recursive","file","getTargetFile","filename","targetFile","copyFileSync","extGroup","addPbxGroup","groups","hash","objects","Object","keys","forEach","key","name","undefined","addToPbxGroup","uuid","projObjects","writeFileSync","writeSync","withCioAppdelegateXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport fs from 'fs';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\nconst addNotificationServiceExtensionFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = options;\n\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n fs.mkdirSync(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const file = 'PushNotification.swift';\n\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n\n const targetFile = getTargetFile(file);\n fs.copyFileSync(`${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`, targetFile);\n\n // Create new PBXGroup for the extension\n const extGroup = xcodeProject.addPbxGroup([file], appName, appName);\n\n // Add the new PBXGroup to the top level group. This makes the\n // files / folder appear in the file explorer in Xcode.\n const groups = xcodeProject.hash.project.objects['PBXGroup'];\n Object.keys(groups).forEach((key) => {\n if (groups[key].name === undefined) {\n xcodeProject.addToPbxGroup(extGroup.uuid, key);\n }\n });\n\n // WORK AROUND for codeProject.addTarget BUG\n // Xcode projects don't contain these if there is only one target\n // An upstream fix should be made to the code referenced in this link:\n // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860\n const projObjects = xcodeProject.hash.project.objects;\n projObjects['PBXTargetDependency'] =\n projObjects['PBXTargetDependency'] || {};\n projObjects['PBXContainerItemProxy'] =\n projObjects['PBXTargetDependency'] || {};\n\n fs.writeFileSync(projPath, xcodeProject.writeSync());\n });\n};\n\nexport const withCioAppdelegateXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber ?? DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationServiceExtensionFile(options);\n\n return config;\n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,KAAKhB,SAAS,EAAE;MAC7B,MAAM,IAAIpB,KAAK,CACb,6EAA6E,CAC9E;IACH;IAEA,MAAMR,OAAO,GAAG;MACd0C,WAAW;MACXI,gBAAgB;MAChBL,kBAAkB;MAClBO,aAAa,EAAED,WAAW,IAAIlD,sBAAsB;MACpDI,OAAO,EAAE4C,mBAAmB;MAC5B3C,OAAO,EAAE0C,WAAW;MACpBD;IACF,CAAC;IAED,MAAM5C,mCAAmC,CAACC,OAAO,CAAC;IAElD,OAAOqC,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"names":["withXcodeProject","xcode","DEFAULT_BUNDLE_VERSION","LOCAL_PATH_TO_CIO_NSE_FILES","FileManagement","addNotificationSwiftFile","options","iosPath","appName","projPath","xcodeProject","project","parse","err","file","getTargetFile","filename","Error","JSON","stringify","exists","mkdir","recursive","targetFile","copyFile","console","log","withCioAppdelegateXcodeProject","configOuter","props","config","modRequest","ios","version","bundleShortVersion","appleTeamId","iosDeploymentTarget","undefined","projectName","platformProjectRoot","bundleIdentifier","buildNumber","bundleVersion"],"sources":["withAppDelegateXcodeProject.ts"],"sourcesContent":["import { ConfigPlugin, withXcodeProject } from '@expo/config-plugins';\nimport xcode from 'xcode';\n\nimport {\n DEFAULT_BUNDLE_VERSION,\n LOCAL_PATH_TO_CIO_NSE_FILES,\n} from '../helpers/constants/ios';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { FileManagement } from './../helpers/utils/fileManagement';\n\nconst addNotificationSwiftFile = async (\n options: CustomerIOPluginOptionsIOS\n) => {\n const { iosPath, appName } = options;\n const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;\n const xcodeProject = xcode.project(projPath);\n\n xcodeProject.parse(async function (err: Error) {\n const file = 'PushNotification.swift';\n const getTargetFile = (filename: string) =>\n `${iosPath}/${appName}/${filename}`;\n if (err) {\n throw new Error(`Error parsing iOS project: ${JSON.stringify(err)}`);\n }\n\n if (!FileManagement.exists(getTargetFile(file))) {\n FileManagement.mkdir(`${iosPath}/${appName}`, {\n recursive: true,\n });\n\n const targetFile = getTargetFile(file);\n FileManagement.copyFile(\n `${LOCAL_PATH_TO_CIO_NSE_FILES}/${file}`,\n targetFile\n );\n } else {\n console.log(`${getTargetFile(file)} already exists. Skipping...`);\n }\n });\n};\n\nexport const withCioAppdelegateXcodeProject: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\n return withXcodeProject(configOuter, async (config) => {\n const { modRequest, ios, version: bundleShortVersion } = config;\n const { appleTeamId, iosDeploymentTarget } = props;\n\n if (ios === undefined)\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios config missing from app.config.js.'\n );\n\n const { projectName, platformProjectRoot } = modRequest;\n const { bundleIdentifier, buildNumber } = ios;\n\n if (bundleShortVersion === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: version missing from app.config.js'\n );\n }\n\n if (bundleIdentifier === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: ios.bundleIdentifier missing from app.config.js'\n );\n }\n\n if (projectName === undefined) {\n throw new Error(\n 'Adding NotificationServiceExtension failed: name missing from app.config.js'\n );\n }\n\n const options = {\n appleTeamId,\n bundleIdentifier,\n bundleShortVersion,\n bundleVersion: buildNumber || DEFAULT_BUNDLE_VERSION,\n iosPath: platformProjectRoot,\n appName: projectName,\n iosDeploymentTarget,\n };\n\n await addNotificationSwiftFile(options);\n\n return config;\n });\n};\n"],"mappings":"AAAA,SAAuBA,gBAAgB,QAAQ,sBAAsB;AACrE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SACEC,sBAAsB,EACtBC,2BAA2B,QACtB,0BAA0B;AAEjC,SAASC,cAAc,QAAQ,mCAAmC;AAElE,MAAMC,wBAAwB,GAAG,MAC/BC,OAAmC,IAChC;EACH,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EACpC,MAAMG,QAAQ,GAAI,GAAEF,OAAQ,IAAGC,O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GR,UAAU;IACvD,MAAM;MAAES,gBAAgB;MAAEC;IAAY,CAAC,GAAGT,GAAG;IAE7C,IAAIE,kBAAkB,KAAKG,SAAS,EAAE;MACpC,MAAM,IAAIpB,KAAK,CACb,gFAAgF,CACjF;IACH;IAEA,IAAIuB,gBAAgB,KAAKH,SAAS,EAAE;MAClC,MAAM,IAAIpB,KAAK,CACb,6FAA6F,CAC9F;IACH;IAEA,IAAIqB,WAAW,KAAKD,SAAS,EAAE;MAC7B,MAAM,IAAIpB,KAAK,CACb,6EAA6E,CAC9E;IACH;IAEA,MAAMX,OAAO,GAAG;MACd6B,WAAW;MACXK,gBAAgB;MAChBN,kBAAkB;MAClBQ,aAAa,EAAED,WAAW,IAAIvC,sBAAsB;MACpDK,OAAO,EAAEgC,mBAAmB;MAC5B/B,OAAO,EAAE8B,WAAW;MACpBF;IACF,CAAC;IAED,MAAM/B,wBAAwB,CAACC,OAAO,CAAC;IAEvC,OAAOwB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC"}
@@ -3,10 +3,15 @@ import { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';
3
3
  import { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';
4
4
  import { withCioXcodeProject } from './withXcodeProject';
5
5
  export function withCIOIos(config, props) {
6
- config = withCioNotificationsXcodeProject(config, props);
7
- config = withAppDelegateModifications(config, props);
6
+ var _props$pushNotificati;
7
+ if ((_props$pushNotificati = props.pushNotification) !== null && _props$pushNotificati !== void 0 && _props$pushNotificati.useRichPush) {
8
+ config = withCioNotificationsXcodeProject(config, props);
9
+ }
10
+ if (props.pushNotification) {
11
+ config = withAppDelegateModifications(config, props);
12
+ config = withCioAppdelegateXcodeProject(config, props);
13
+ }
8
14
  config = withCioXcodeProject(config, props);
9
- config = withCioAppdelegateXcodeProject(config, props);
10
15
  return config;
11
16
  }
12
17
  //# sourceMappingURL=withCIOIos.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n config = withCioNotificationsXcodeProject(config, props);\n config = withAppDelegateModifications(config, props);\n config = withCioXcodeProject(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,8BAA8B,QAAQ,+BAA+B;AAC9E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACAD,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;EACxDD,MAAM,GAAGL,4BAA4B,CAACK,MAAM,EAAEC,KAAK,CAAC;EACpDD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAC3CD,MAAM,GAAGJ,8BAA8B,CAACI,MAAM,EAAEC,KAAK,CAAC;EAEtD,OAAOD,MAAM;AACf"}
1
+ {"version":3,"names":["withAppDelegateModifications","withCioAppdelegateXcodeProject","withCioNotificationsXcodeProject","withCioXcodeProject","withCIOIos","config","props","pushNotification","useRichPush"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioAppdelegateXcodeProject } from './withAppDelegateXcodeProject';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification?.useRichPush) {\n config = withCioNotificationsXcodeProject(config, props);\n }\n\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioAppdelegateXcodeProject(config, props);\n }\n\n config = withCioXcodeProject(config, props);\n\n return config;\n}\n"],"mappings":"AAGA,SAASA,4BAA4B,QAAQ,gCAAgC;AAC7E,SAASC,8BAA8B,QAAQ,+BAA+B;AAC9E,SAASC,gCAAgC,QAAQ,iCAAiC;AAClF,SAASC,mBAAmB,QAAQ,oBAAoB;AAExD,OAAO,SAASC,UAAU,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EAAA;EACA,6BAAIA,KAAK,CAACC,gBAAgB,kDAAtB,sBAAwBC,WAAW,EAAE;IACvCH,MAAM,GAAGH,gCAAgC,CAACG,MAAM,EAAEC,KAAK,CAAC;EAC1D;EAEA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAGL,4BAA4B,CAACK,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAGJ,8BAA8B,CAACI,MAAM,EAAEC,KAAK,CAAC;EACxD;EAEAD,MAAM,GAAGF,mBAAmB,CAACE,MAAM,EAAEC,KAAK,CAAC;EAE3C,OAAOD,MAAM;AACf"}