customerio-expo-plugin 2.0.0-beta.1 → 2.0.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.
- package/package.json +11 -5
- package/plugin/{src/helpers/native-files/ios → lib/commonjs/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/ios/utils.js +17 -0
- package/plugin/lib/commonjs/ios/utils.js.map +1 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +2 -0
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +68 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +2 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/{commonjs/helpers/native-files/ios → module/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +4 -4
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/ios/utils.js +10 -0
- package/plugin/lib/module/ios/utils.js.map +1 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js +8 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +2 -0
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +61 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +29 -11
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +2 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -2
- package/plugin/lib/typescript/ios/utils.d.ts +7 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +3 -0
- package/plugin/lib/typescript/types/cio-types.d.ts +3 -0
- package/plugin/{lib/module/helpers/native-files/ios → src/helpers/native-files/ios/apn}/PushService.swift +1 -0
- package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +25 -0
- package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +59 -0
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +5 -4
- package/plugin/src/ios/utils.ts +10 -0
- package/plugin/src/ios/withAppDelegateModifications.ts +15 -0
- package/plugin/src/ios/withCIOIos.ts +2 -0
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +97 -0
- package/plugin/src/ios/withNotificationsXcodeProject.ts +40 -12
- package/plugin/src/ios/withXcodeProject.ts +2 -1
- package/plugin/src/types/cio-types.ts +3 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/commonjs/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/lib/module/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.swift → apn/NotificationService.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{Env.swift → common/Env.swift} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService-Info.plist → common/NotificationService-Info.plist} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.h → common/NotificationService.h} +0 -0
- /package/plugin/src/helpers/native-files/ios/{NotificationService.m → common/NotificationService.m} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "2.0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "plugin/lib/commonjs/index",
|
|
6
6
|
"module": "plugin/lib/module/index",
|
|
@@ -27,9 +27,14 @@
|
|
|
27
27
|
"prepare": "npm run clean && bob build",
|
|
28
28
|
"postinstall": "node plugin/src/postInstall.js",
|
|
29
29
|
"test": "jest",
|
|
30
|
-
"
|
|
30
|
+
"compatibility:create-test-app": "node scripts/compatibility/create-test-app.js",
|
|
31
|
+
"compatibility:setup-test-app": "node scripts/compatibility/setup-test-app.js",
|
|
32
|
+
"compatibility:configure-plugin": "node scripts/compatibility/configure-plugin.js",
|
|
33
|
+
"compatibility:validate-plugin": "node scripts/compatibility/validate-plugin.js",
|
|
34
|
+
"compatibility:run-compatibility-tests": "node scripts/compatibility/run-compatibility-tests.js",
|
|
35
|
+
"setup-test-app": "bash scripts/setup-test-app.sh",
|
|
31
36
|
"cleanup": "bash scripts/cleanup-after-tests.sh",
|
|
32
|
-
"test-plugin": "npm run setup-
|
|
37
|
+
"test-plugin": "npm run setup-test-app && npm run test && npm run cleanup",
|
|
33
38
|
"cleanAll": "bash scripts/clean-all.sh",
|
|
34
39
|
"buildAll": "bash scripts/build-all.sh",
|
|
35
40
|
"cleanAndBuildAll": "npm run cleanAll && npm run buildAll"
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
"registry": "https://registry.npmjs.org/"
|
|
50
55
|
},
|
|
51
56
|
"peerDependencies": {
|
|
52
|
-
"customerio-reactnative": "
|
|
57
|
+
"customerio-reactnative": "4.2.2"
|
|
53
58
|
},
|
|
54
59
|
"devDependencies": {
|
|
55
60
|
"@expo/config-plugins": "^4.1.4",
|
|
@@ -68,7 +73,8 @@
|
|
|
68
73
|
"@types/jest": "^29.5.14",
|
|
69
74
|
"jest": "^29.7.0",
|
|
70
75
|
"jest-environment-jsdom": "^29.7.0",
|
|
71
|
-
"ts-jest": "^29.2.5"
|
|
76
|
+
"ts-jest": "^29.2.5",
|
|
77
|
+
"gradle-to-js": "^2.0.1"
|
|
72
78
|
},
|
|
73
79
|
"commitlint": {
|
|
74
80
|
"extends": [
|
|
@@ -14,6 +14,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
14
14
|
public func initializeCioSdk() {
|
|
15
15
|
MessagingPushAPN.initialize(
|
|
16
16
|
withConfig: MessagingPushConfigBuilder()
|
|
17
|
+
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
17
18
|
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
18
19
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
19
20
|
.build()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UserNotifications
|
|
3
|
+
import CioMessagingPushFCM
|
|
4
|
+
|
|
5
|
+
@objc
|
|
6
|
+
public class NotificationServiceCioManager : NSObject {
|
|
7
|
+
|
|
8
|
+
public override init() {}
|
|
9
|
+
|
|
10
|
+
@objc(didReceive:withContentHandler:)
|
|
11
|
+
public func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
|
12
|
+
MessagingPushFCM.initializeForExtension(
|
|
13
|
+
withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
|
|
14
|
+
.region(Env.customerIORegion)
|
|
15
|
+
.build()
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
@objc(serviceExtensionTimeWillExpire)
|
|
22
|
+
public func serviceExtensionTimeWillExpire() {
|
|
23
|
+
MessagingPush.shared.serviceExtensionTimeWillExpire()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import CioMessagingPushFCM
|
|
3
|
+
import FirebaseCore
|
|
4
|
+
import FirebaseMessaging
|
|
5
|
+
import UserNotifications
|
|
6
|
+
import UIKit
|
|
7
|
+
|
|
8
|
+
@objc
|
|
9
|
+
public class CIOAppPushNotificationsHandler : NSObject {
|
|
10
|
+
|
|
11
|
+
public override init() {}
|
|
12
|
+
|
|
13
|
+
{{REGISTER_SNIPPET}}
|
|
14
|
+
|
|
15
|
+
@objc(initializeCioSdk)
|
|
16
|
+
public func initializeCioSdk() {
|
|
17
|
+
if (FirebaseApp.app() == nil) {
|
|
18
|
+
FirebaseApp.configure()
|
|
19
|
+
}
|
|
20
|
+
Messaging.messaging().delegate = self
|
|
21
|
+
UIApplication.shared.registerForRemoteNotifications()
|
|
22
|
+
|
|
23
|
+
MessagingPushFCM.initialize(
|
|
24
|
+
withConfig: MessagingPushConfigBuilder()
|
|
25
|
+
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
26
|
+
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
27
|
+
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
28
|
+
.build()
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc(application:deviceToken:)
|
|
33
|
+
public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
34
|
+
// Do nothing for FCM version
|
|
35
|
+
// This is not needed for FCM but keeping it to prevent modification or breaking compatibility with older versions
|
|
36
|
+
// of Expo plugin
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@objc(application:error:)
|
|
40
|
+
public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
41
|
+
// Do nothing for FCM version
|
|
42
|
+
// This is not needed for FCM but keeping it to prevent modification or breaking compatibility with older versions
|
|
43
|
+
// of Expo plugin
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
extension CIOAppPushNotificationsHandler: MessagingDelegate {
|
|
48
|
+
public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
|
|
49
|
+
MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func userNotificationCenter(
|
|
53
|
+
_ center: UNUserNotificationCenter,
|
|
54
|
+
willPresent notification: UNNotification,
|
|
55
|
+
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
|
|
56
|
+
) {
|
|
57
|
+
completionHandler([.list, .banner, .badge, .sound])
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -8,7 +8,7 @@ exports.injectCIOPodfileCode = injectCIOPodfileCode;
|
|
|
8
8
|
var _ios = require("../constants/ios");
|
|
9
9
|
var _codeInjection = require("./codeInjection");
|
|
10
10
|
var _fileManagement = require("./fileManagement");
|
|
11
|
-
async function injectCIOPodfileCode(iosPath) {
|
|
11
|
+
async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
|
|
12
12
|
const blockStart = '# --- CustomerIO Host App START ---';
|
|
13
13
|
const blockEnd = '# --- CustomerIO Host App END ---';
|
|
14
14
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -21,7 +21,7 @@ async function injectCIOPodfileCode(iosPath) {
|
|
|
21
21
|
const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
|
|
22
22
|
const snippetToInjectInPodfile = `
|
|
23
23
|
${blockStart}
|
|
24
|
-
pod 'customerio-reactnative
|
|
24
|
+
pod 'customerio-reactnative/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${(0, _ios.getRelativePathToRNSDK)(iosPath)}'
|
|
25
25
|
${blockEnd}
|
|
26
26
|
`.trim();
|
|
27
27
|
_fileManagement.FileManagement.write(filename, (0, _codeInjection.injectCodeByRegex)(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
@@ -29,7 +29,7 @@ ${blockEnd}
|
|
|
29
29
|
console.log('CustomerIO Podfile snippets already exists. Skipping...');
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
async function injectCIONotificationPodfileCode(iosPath, useFrameworks) {
|
|
32
|
+
async function injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmPushProvider) {
|
|
33
33
|
const filename = `${iosPath}/Podfile`;
|
|
34
34
|
const podfile = await _fileManagement.FileManagement.read(filename);
|
|
35
35
|
const blockStart = '# --- CustomerIO Notification START ---';
|
|
@@ -40,7 +40,7 @@ async function injectCIONotificationPodfileCode(iosPath, useFrameworks) {
|
|
|
40
40
|
${blockStart}
|
|
41
41
|
target 'NotificationService' do
|
|
42
42
|
${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
|
|
43
|
-
pod 'customerio-reactnative-richpush
|
|
43
|
+
pod 'customerio-reactnative-richpush/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${(0, _ios.getRelativePathToRNSDK)(iosPath)}'
|
|
44
44
|
end
|
|
45
45
|
${blockEnd}
|
|
46
46
|
`.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ios","require","_codeInjection","_fileManagement","injectCIOPodfileCode","iosPath","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","getRelativePathToRNSDK","trim","write","injectCodeByRegex","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string) {\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
|
|
1
|
+
{"version":3,"names":["_ios","require","_codeInjection","_fileManagement","injectCIOPodfileCode","iosPath","isFcmPushProvider","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","snippetToInjectInPodfile","getRelativePathToRNSDK","trim","write","injectCodeByRegex","join","console","log","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport async function injectCIOPodfileCode(iosPath: string, isFcmPushProvider: boolean) {\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\"}', :path => '${getRelativePathToRNSDK(\n iosPath\n )}'\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 console.log('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\"}', :path => '${getRelativePathToRNSDK(\n iosPath\n )}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEO,eAAeG,oBAAoBA,CAACC,OAAe,EAAEC,iBAA0B,EAAE;EACtF,MAAMC,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,wBAAwB,GAAG;AACrC,EAAEV,UAAU;AACZ,gCAAgCD,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAAgB,IAAAY,2BAAsB,EACnGb,OACF,CAAC;AACH,EAAEG,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACS,KAAK,CAClBX,QAAQ,EACR,IAAAY,gCAAiB,EACfX,OAAO,EACPM,kCAAkC,EAClCC,wBACF,CAAC,CAACK,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,OAAO,CAACC,GAAG,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgCA,CACpDpB,OAAe,EACfqB,aAA0D,EAC1DpB,iBAA0B,EAC1B;EACA,MAAMG,QAAQ,GAAG,GAAGJ,OAAO,UAAU;EACrC,MAAMK,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMI,wBAAwB,GAAG;AACrC,EAAEV,UAAU;AACZ;AACA,IAAImB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyCpB,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBAAgB,IAAAY,2BAAsB,EAC5Gb,OACF,CAAC;AACH;AACA,EAAEG,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACgB,MAAM,CAAClB,QAAQ,EAAEQ,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isFcmPushProvider = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Returns t
|
|
9
|
+
* @param iosOptions The plugin iOS configuration options
|
|
10
|
+
* @returns true if FCM is configured to be used as push provider
|
|
11
|
+
*/
|
|
12
|
+
const isFcmPushProvider = iosOptions => {
|
|
13
|
+
var _iosOptions$pushNotif;
|
|
14
|
+
return (iosOptions === null || iosOptions === void 0 || (_iosOptions$pushNotif = iosOptions.pushNotification) === null || _iosOptions$pushNotif === void 0 ? void 0 : _iosOptions$pushNotif.provider) === "fcm";
|
|
15
|
+
};
|
|
16
|
+
exports.isFcmPushProvider = isFcmPushProvider;
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isFcmPushProvider","iosOptions","_iosOptions$pushNotif","pushNotification","provider","exports"],"sources":["utils.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\n\n/**\n * Returns t\n * @param iosOptions The plugin iOS configuration options\n * @returns true if FCM is configured to be used as push provider\n */\nexport const isFcmPushProvider = (iosOptions?: CustomerIOPluginOptionsIOS): boolean => {\n return iosOptions?.pushNotification?.provider === \"fcm\";\n};"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAAIC,UAAuC,IAAc;EAAA,IAAAC,qBAAA;EACnF,OAAO,CAAAD,UAAU,aAAVA,UAAU,gBAAAC,qBAAA,GAAVD,UAAU,CAAEE,gBAAgB,cAAAD,qBAAA,uBAA5BA,qBAAA,CAA8BE,QAAQ,MAAK,KAAK;AAC3D,CAAC;AAACC,OAAA,CAAAL,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _Paths = require("@expo/config-plugins/build/ios/Paths");
|
|
|
9
9
|
var _ios = require("../helpers/constants/ios");
|
|
10
10
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
11
11
|
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
12
|
+
var _utils = require("./utils");
|
|
12
13
|
const addImport = (stringContents, appName) => {
|
|
13
14
|
const importRegex = /^(#import .*)\n/gm;
|
|
14
15
|
const addedImport = getImportSnippet(appName);
|
|
@@ -59,6 +60,10 @@ const addExpoNotificationsHeaderModification = stringContents => {
|
|
|
59
60
|
`);
|
|
60
61
|
return stringContents;
|
|
61
62
|
};
|
|
63
|
+
const addFirebaseDelegateForwardDeclarationIfNeeded = stringContents => {
|
|
64
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, 0, '@protocol FIRMessagingDelegate;');
|
|
65
|
+
return stringContents;
|
|
66
|
+
};
|
|
62
67
|
const addAppdelegateHeaderModification = stringContents => {
|
|
63
68
|
// Add UNUserNotificationCenterDelegate if needed
|
|
64
69
|
stringContents = stringContents.replace(_ios.CIO_APPDELEGATEHEADER_REGEX, (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
|
|
@@ -124,6 +129,9 @@ const withAppDelegateModifications = (configOuter, props) => {
|
|
|
124
129
|
}
|
|
125
130
|
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
126
131
|
stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
132
|
+
if ((0, _utils.isFcmPushProvider)(props)) {
|
|
133
|
+
stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);
|
|
134
|
+
}
|
|
127
135
|
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
128
136
|
config.modResults.contents = stringContents;
|
|
129
137
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_Paths","_ios","_codeInjection","_fileManagement","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","injectCodeBeforeMultiLineRegex","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addInitializeNativeCioSdk","CIO_INITIALIZECIOSDK_SNIPPET","addHandleDeeplinkInKilledStateConfiguration","regex","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","addDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addExpoNotificationsHeaderModification","addAppdelegateHeaderModification","replace","CIO_APPDELEGATEHEADER_REGEX","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","trim","addHandleDeeplinkInKilledState","matchRegexExists","CIO_DEEPLINK_COMMENT_REGEX","snippet","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","replaceCodeByRegex","withAppDelegateModifications","configOuter","props","withAppDelegate","config","modResults","contents","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","disableNotificationRegistration","handleDeeplinkInKilledState","console","log","exports"],"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_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\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 );\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 = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_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\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet = undefined;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\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\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (\n props.handleDeeplinkInKilledState !== undefined &&\n props.handleDeeplinkInKilledState === true\n ) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n stringContents = addExpoNotificationsHeaderModification(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,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAoBA,IAAAG,cAAA,GAAAH,OAAA;AAQA,IAAAI,eAAA,GAAAJ,OAAA;AAGA,MAAMK,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;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K,EAC/C;QACApE,cAAc,GAAGe,4BAA4B,CAACf,cAAc,CAAC;MAC/D;MAEAA,cAAc,GAAGmB,yBAAyB,CAACnB,cAAc,CAAC;MAE1D,IACEqD,KAAK,CAACgB,2BAA2B,KAAK7D,SAAS,IAC/C6C,KAAK,CAACgB,2BAA2B,KAAK,IAAI,EAC1C;QACArE,cAAc,GAAG0C,8BAA8B,CAAC1C,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZwB,mDAAmD,CAACxB,cAAc,CAAC;MACrEA,cAAc,GACZ4B,mDAAmD,CAAC5B,cAAc,CAAC;MAErEA,cAAc,GAAG+B,sCAAsC,CAAC/B,cAAc,CAAC;MAEvEuD,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAGzD,cAAc;IAC7C,CAAC,MAAM;MACLsE,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOhB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACiB,OAAA,CAAArB,4BAAA,GAAAA,4BAAA;AACF,SAAS/C,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_Paths","_ios","_codeInjection","_fileManagement","_utils","addImport","stringContents","appName","importRegex","addedImport","getImportSnippet","match","endOfMatchIndex","index","undefined","length","injectCodeByLineNumber","addNotificationHandlerDeclaration","injectCodeByMultiLineRegex","CIO_APPDELEGATEDECLARATION_REGEX","CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET","addNotificationConfiguration","injectCodeBeforeMultiLineRegex","CIO_DIDFINISHLAUNCHINGMETHOD_REGEX","CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET","addInitializeNativeCioSdk","CIO_INITIALIZECIOSDK_SNIPPET","addHandleDeeplinkInKilledStateConfiguration","regex","CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET","addDidFailToRegisterForRemoteNotificationsWithError","injectCodeByMultiLineRegexAndReplaceLine","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX","CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET","addDidRegisterForRemoteNotificationsWithDeviceToken","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX","CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET","addExpoNotificationsHeaderModification","addFirebaseDelegateForwardDeclarationIfNeeded","addAppdelegateHeaderModification","replace","CIO_APPDELEGATEHEADER_REGEX","interfaceDeclaration","_groupedDelegates","existingDelegates","includes","CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET","CIO_APPDELEGATEHEADER_IMPORT_SNIPPET","trim","addHandleDeeplinkInKilledState","matchRegexExists","CIO_DEEPLINK_COMMENT_REGEX","snippet","CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX","CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET","CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET","replaceCodeByRegex","withAppDelegateModifications","configOuter","props","withAppDelegate","config","modResults","contents","RegExp","modRequest","projectName","headerPath","getAppDelegateHeaderFilePath","projectRoot","headerContent","FileManagement","read","write","disableNotificationRegistration","handleDeeplinkInKilledState","isFcmPushProvider","console","log","exports"],"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_IMPORT_SNIPPET,\n CIO_APPDELEGATEHEADER_REGEX,\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX,\n CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX,\n CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX,\n CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET,\n CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET,\n CIO_DEEPLINK_COMMENT_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET,\n} from '../helpers/constants/ios';\nimport {\n injectCodeBeforeMultiLineRegex,\n injectCodeByLineNumber,\n injectCodeByMultiLineRegex,\n injectCodeByMultiLineRegexAndReplaceLine,\n replaceCodeByRegex,\n matchRegexExists,\n} from '../helpers/utils/codeInjection';\nimport { FileManagement } from '../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\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 );\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 = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addInitializeNativeCioSdk = (stringContents: string) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n CIO_DIDFINISHLAUNCHINGMETHOD_REGEX,\n CIO_INITIALIZECIOSDK_SNIPPET\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledStateConfiguration = (\n stringContents: string,\n regex: RegExp\n) => {\n stringContents = injectCodeBeforeMultiLineRegex(\n stringContents,\n regex,\n CIO_CONFIGUREDEEPLINK_KILLEDSTATE_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\n// Adds required import for Expo Notifications package in AppDelegate.\n// Required to call functions from the package.\nconst addExpoNotificationsHeaderModification = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n `\n#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)\n#import <EXNotifications/EXNotificationCenterDelegate.h>\n#endif\n`\n );\n\n return stringContents;\n};\n\nconst addFirebaseDelegateForwardDeclarationIfNeeded = (stringContents: string) => {\n stringContents = injectCodeByLineNumber(\n stringContents,\n 0,\n '@protocol FIRMessagingDelegate;'\n );\n\n return stringContents;\n};\n\nconst addAppdelegateHeaderModification = (stringContents: string) => {\n // Add UNUserNotificationCenterDelegate if needed\n stringContents = stringContents.replace(\n CIO_APPDELEGATEHEADER_REGEX,\n (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {\n if (\n existingDelegates &&\n existingDelegates.includes(\n CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET\n )\n ) {\n // The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it\n return match;\n } else if (existingDelegates) {\n // Other delegates exist, append ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration}<${existingDelegates}, ${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n } else {\n // No delegates exist, add ours\n return `${CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}\n${interfaceDeclaration.trim()} <${CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>\n`;\n }\n }\n );\n\n return stringContents;\n};\n\nconst addHandleDeeplinkInKilledState = (stringContents: string) => {\n // Find if the deep link code snippet is already present\n if (matchRegexExists(stringContents, CIO_DEEPLINK_COMMENT_REGEX)) {\n return stringContents;\n }\n\n // Check if the app delegate is using RCTBridge or LaunchOptions\n let snippet = undefined;\n let regex = CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n if (\n matchRegexExists(\n stringContents,\n CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;\n regex = CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;\n } else if (\n matchRegexExists(\n stringContents,\n CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX\n )\n ) {\n snippet = CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;\n }\n // Add code only if the app delegate is using RCTBridge or LaunchOptions\n if (snippet !== undefined) {\n stringContents = addHandleDeeplinkInKilledStateConfiguration(\n stringContents,\n regex\n );\n stringContents = replaceCodeByRegex(stringContents, regex, snippet);\n }\n return stringContents;\n};\n\nexport const withAppDelegateModifications: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (configOuter, props) => {\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\n // any other value would be treated as true, it has to be explicitly false to disable\n if (\n props.disableNotificationRegistration !== undefined &&\n props.disableNotificationRegistration === false\n ) {\n stringContents = addNotificationConfiguration(stringContents);\n }\n\n stringContents = addInitializeNativeCioSdk(stringContents);\n\n if (\n props.handleDeeplinkInKilledState !== undefined &&\n props.handleDeeplinkInKilledState === true\n ) {\n stringContents = addHandleDeeplinkInKilledState(stringContents);\n }\n\n stringContents =\n addDidFailToRegisterForRemoteNotificationsWithError(stringContents);\n stringContents =\n addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);\n\n if (isFcmPushProvider(props)) {\n stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);\n } \n\n stringContents = addExpoNotificationsHeaderModification(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,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAoBA,IAAAG,cAAA,GAAAH,OAAA;AAQA,IAAAI,eAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,MAAMM,SAAS,GAAGA,CAACC,cAAsB,EAAEC,OAAe,KAAK;EAC7D,MAAMC,WAAW,GAAG,mBAAmB;EACvC,MAAMC,WAAW,GAAGC,gBAAgB,CAACH,OAAO,CAAC;EAE7C,MAAMI,KAAK,GAAGL,cAAc,CAACK,KAAK,CAACH,WAAW,CAAC;EAC/C,IAAII,eAAuB;EAC3B,IAAI,CAACD,KAAK,IAAIA,KAAK,CAACE,KAAK,KAAKC,SAAS,EAAE;IACvC;IACAF,eAAe,GAAG,CAAC;EACrB,CAAC,MAAM;IACL;IACAA,eAAe,GAAGD,KAAK,CAACE,KAAK,GAAGF,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;EACjD;EAEAT,cAAc,GAAG,IAAAU,qCAAsB,EACrCV,cAAc,EACdM,eAAe,EACfH,WACF,CAAC;EAED,OAAOH,cAAc;AACvB,CAAC;AAED,MAAMW,iCAAiC,GAAIX,cAAsB,IAAK;EACpEA,cAAc,GAAG,IAAAY,yCAA0B,EACzCZ,cAAc,EACda,qCAAgC,EAChCC,mDACF,CAAC;EAED,OAAOd,cAAc;AACvB,CAAC;AAED,MAAMe,4BAA4B,GAAIf,cAAsB,IAAK;EAC/DA,cAAc,GAAG,IAAAgB,6CAA8B,EAC7ChB,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c,GAAG+B,sCAAsC,CAAC/B,cAAc,CAAC;MAEvEwD,MAAM,CAACC,UAAU,CAACC,QAAQ,GAAG1D,cAAc;IAC7C,CAAC,MAAM;MACLwE,OAAO,CAACC,GAAG,CAAC,2DAA2D,CAAC;IAC1E;IAEA,OAAOjB,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACkB,OAAA,CAAAtB,4BAAA,GAAAA,4BAAA;AACF,SAAShD,gBAAgBA,CAACH,OAAe,EAAE;EACzC,OAAO;AACT;AACA;AACA,WAAWA,OAAO;AAClB,GAAG;AACH","ignoreList":[]}
|
|
@@ -7,11 +7,13 @@ exports.withCIOIos = withCIOIos;
|
|
|
7
7
|
var _withAppDelegateModifications = require("./withAppDelegateModifications");
|
|
8
8
|
var _withNotificationsXcodeProject = require("./withNotificationsXcodeProject");
|
|
9
9
|
var _withXcodeProject = require("./withXcodeProject");
|
|
10
|
+
var _withGoogleServicesJsonFile = require("./withGoogleServicesJsonFile");
|
|
10
11
|
function withCIOIos(config, props) {
|
|
11
12
|
if (props.pushNotification) {
|
|
12
13
|
config = (0, _withAppDelegateModifications.withAppDelegateModifications)(config, props);
|
|
13
14
|
config = (0, _withNotificationsXcodeProject.withCioNotificationsXcodeProject)(config, props);
|
|
14
15
|
config = (0, _withXcodeProject.withCioXcodeProject)(config, props);
|
|
16
|
+
config = (0, _withGoogleServicesJsonFile.withGoogleServicesJsonFile)(config, props);
|
|
15
17
|
}
|
|
16
18
|
return config;
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withAppDelegateModifications","require","_withNotificationsXcodeProject","_withXcodeProject","withCIOIos","config","props","pushNotification","withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n }\n\n return config;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,6BAAA,GAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,
|
|
1
|
+
{"version":3,"names":["_withAppDelegateModifications","require","_withNotificationsXcodeProject","_withXcodeProject","_withGoogleServicesJsonFile","withCIOIos","config","props","pushNotification","withAppDelegateModifications","withCioNotificationsXcodeProject","withCioXcodeProject","withGoogleServicesJsonFile"],"sources":["withCIOIos.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { withAppDelegateModifications } from './withAppDelegateModifications';\nimport { withCioNotificationsXcodeProject } from './withNotificationsXcodeProject';\nimport { withCioXcodeProject } from './withXcodeProject';\nimport { withGoogleServicesJsonFile } from './withGoogleServicesJsonFile';\n\nexport function withCIOIos(\n config: ExpoConfig,\n props: CustomerIOPluginOptionsIOS\n) {\n if (props.pushNotification) {\n config = withAppDelegateModifications(config, props);\n config = withCioNotificationsXcodeProject(config, props);\n config = withCioXcodeProject(config, props);\n config = withGoogleServicesJsonFile(config, props);\n }\n\n return config;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,6BAAA,GAAAC,OAAA;AACA,IAAAC,8BAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAEO,SAASI,UAAUA,CACxBC,MAAkB,EAClBC,KAAiC,EACjC;EACA,IAAIA,KAAK,CAACC,gBAAgB,EAAE;IAC1BF,MAAM,GAAG,IAAAG,0DAA4B,EAACH,MAAM,EAAEC,KAAK,CAAC;IACpDD,MAAM,GAAG,IAAAI,+DAAgC,EAACJ,MAAM,EAAEC,KAAK,CAAC;IACxDD,MAAM,GAAG,IAAAK,qCAAmB,EAACL,MAAM,EAAEC,KAAK,CAAC;IAC3CD,MAAM,GAAG,IAAAM,sDAA0B,EAACN,MAAM,EAAEC,KAAK,CAAC;EACpD;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withGoogleServicesJsonFile = void 0;
|
|
7
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
const withGoogleServicesJsonFile = (config, cioProps) => {
|
|
11
|
+
return (0, _configPlugins.withXcodeProject)(config, async props => {
|
|
12
|
+
var _cioProps$pushNotific;
|
|
13
|
+
const useFcm = (0, _utils.isFcmPushProvider)(cioProps);
|
|
14
|
+
if (!useFcm) {
|
|
15
|
+
// Nothing to do, for providers other than FCM, the Google services JSON file isn't needed
|
|
16
|
+
return props;
|
|
17
|
+
}
|
|
18
|
+
console.log('Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' + ' GoogleService-Info.plist as part of Firebase integration');
|
|
19
|
+
|
|
20
|
+
// googleServicesFile
|
|
21
|
+
const iosPath = props.modRequest.platformProjectRoot;
|
|
22
|
+
const googleServicesFile = (_cioProps$pushNotific = cioProps.pushNotification) === null || _cioProps$pushNotific === void 0 ? void 0 : _cioProps$pushNotific.googleServicesFile;
|
|
23
|
+
const appName = props.modRequest.projectName;
|
|
24
|
+
if (_fileManagement.FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {
|
|
25
|
+
console.log(`File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`);
|
|
26
|
+
return props;
|
|
27
|
+
}
|
|
28
|
+
if (_fileManagement.FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)) {
|
|
29
|
+
// This is where RN Firebase potentially copies GoogleService-Info.plist
|
|
30
|
+
// Do not copy if it's already done by Firebase to avoid conflict in Resources
|
|
31
|
+
console.log(`File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`);
|
|
32
|
+
return props;
|
|
33
|
+
}
|
|
34
|
+
if (googleServicesFile && _fileManagement.FileManagement.exists(googleServicesFile)) {
|
|
35
|
+
var _config$ios;
|
|
36
|
+
if ((_config$ios = config.ios) !== null && _config$ios !== void 0 && _config$ios.googleServicesFile) {
|
|
37
|
+
console.warn('Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' + ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile');
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
_fileManagement.FileManagement.copyFile(googleServicesFile, `${iosPath}/GoogleService-Info.plist`);
|
|
41
|
+
addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error(`There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
console.error(`The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`);
|
|
47
|
+
}
|
|
48
|
+
return props;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.withGoogleServicesJsonFile = withGoogleServicesJsonFile;
|
|
52
|
+
function addFileToXcodeProject(project, fileName) {
|
|
53
|
+
const groupName = 'Resources';
|
|
54
|
+
const filepath = fileName;
|
|
55
|
+
if (!_configPlugins.IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {
|
|
56
|
+
console.error(`Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Add GoogleService-Info.plist to the Xcode project
|
|
61
|
+
_configPlugins.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
|
62
|
+
project,
|
|
63
|
+
filepath,
|
|
64
|
+
groupName,
|
|
65
|
+
isBuildFile: true
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=withGoogleServicesJsonFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_fileManagement","_utils","withGoogleServicesJsonFile","config","cioProps","withXcodeProject","props","_cioProps$pushNotific","useFcm","isFcmPushProvider","console","log","iosPath","modRequest","platformProjectRoot","googleServicesFile","pushNotification","appName","projectName","FileManagement","exists","_config$ios","ios","warn","copyFile","addFileToXcodeProject","modResults","e","error","exports","project","fileName","groupName","filepath","IOSConfig","XcodeUtils","ensureGroupRecursively","addResourceFileToGroup","isBuildFile"],"sources":["withGoogleServicesJsonFile.ts"],"sourcesContent":["import {\n withXcodeProject,\n IOSConfig,\n ConfigPlugin,\n} from '@expo/config-plugins';\n\nimport { FileManagement } from './../helpers/utils/fileManagement';\nimport type { CustomerIOPluginOptionsIOS } from '../types/cio-types';\nimport { isFcmPushProvider } from './utils';\n\nexport const withGoogleServicesJsonFile: ConfigPlugin<\n CustomerIOPluginOptionsIOS\n> = (config, cioProps) => {\n return withXcodeProject(config, async (props) => {\n const useFcm = isFcmPushProvider(cioProps);\n if (!useFcm) {\n // Nothing to do, for providers other than FCM, the Google services JSON file isn't needed\n return props;\n }\n\n console.log(\n 'Only specify Customer.io ios.pushNotification.googleServicesFile config if you are not already including' +\n ' GoogleService-Info.plist as part of Firebase integration'\n );\n\n // googleServicesFile\n const iosPath = props.modRequest.platformProjectRoot;\n const googleServicesFile = cioProps.pushNotification?.googleServicesFile;\n const appName = props.modRequest.projectName;\n\n if (FileManagement.exists(`${iosPath}/GoogleService-Info.plist`)) {\n console.log(\n `File already exists: ${iosPath}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (\n FileManagement.exists(`${iosPath}/${appName}/GoogleService-Info.plist`)\n ) {\n // This is where RN Firebase potentially copies GoogleService-Info.plist\n // Do not copy if it's already done by Firebase to avoid conflict in Resources\n console.log(\n `File already exists: ${iosPath}/${appName}/GoogleService-Info.plist. Skipping...`\n );\n return props;\n }\n\n if (googleServicesFile && FileManagement.exists(googleServicesFile)) {\n if (config.ios?.googleServicesFile) {\n console.warn(\n 'Specifying both Expo ios.googleServicesFile and Customer.io ios.pushNotification.googleServicesFile can cause a conflict' +\n ' duplicating GoogleService-Info.plist in the iOS project resources. Please remove Customer.io ios.pushNotification.googleServicesFile'\n );\n }\n\n try {\n FileManagement.copyFile(\n googleServicesFile,\n `${iosPath}/GoogleService-Info.plist`\n );\n\n addFileToXcodeProject(props.modResults, 'GoogleService-Info.plist');\n } catch (e) {\n console.error(\n `There was an error copying your GoogleService-Info.plist file. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n } else {\n console.error(\n `The Google Services file provided in ${googleServicesFile} doesn't seem to exist. You can copy it manually into ${iosPath}/GoogleService-Info.plist`\n );\n }\n\n return props;\n });\n};\n\nfunction addFileToXcodeProject(project: any, fileName: string) {\n const groupName = 'Resources';\n const filepath = fileName;\n\n if (!IOSConfig.XcodeUtils.ensureGroupRecursively(project, groupName)) {\n console.error(\n `Error copying GoogleService-Info.plist. Failed to find or create '${groupName}' group in Xcode.`\n );\n return;\n }\n\n // Add GoogleService-Info.plist to the Xcode project\n IOSConfig.XcodeUtils.addResourceFileToGroup({\n project,\n filepath,\n groupName,\n isBuildFile: true,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,0BAEZ,GAAGA,CAACC,MAAM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oB,UAAU,EAAE,0BAA0B,CAAC;MACrE,CAAC,CAAC,OAAOC,CAAC,EAAE;QACVjB,OAAO,CAACkB,KAAK,CACX,gGAAgGhB,OAAO,2BACzG,CAAC;MACH;IACF,CAAC,MAAM;MACLF,OAAO,CAACkB,KAAK,CACX,wCAAwCb,kBAAkB,yDAAyDH,OAAO,2BAC5H,CAAC;IACH;IAEA,OAAON,KAAK;EACd,CAAC,CAAC;AACJ,CAAC;AAACuB,OAAA,CAAA3B,0BAAA,GAAAA,0BAAA;AAEF,SAASuB,qBAAqBA,CAACK,OAAY,EAAEC,QAAgB,EAAE;EAC7D,MAAMC,SAAS,GAAG,WAAW;EAC7B,MAAMC,QAAQ,GAAGF,QAAQ;EAEzB,IAAI,CAACG,wBAAS,CAACC,UAAU,CAACC,sBAAsB,CAACN,OAAO,EAAEE,SAAS,CAAC,EAAE;IACpEtB,OAAO,CAACkB,KAAK,CACX,qEAAqEI,SAAS,mBAChF,CAAC;IACD;EACF;;EAEA;EACAE,wBAAS,CAACC,UAAU,CAACE,sBAAsB,CAAC;IAC1CP,OAAO;IACPG,QAAQ;IACRD,SAAS;IACTM,WAAW,EAAE;EACf,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -9,6 +9,7 @@ var _ios = require("../helpers/constants/ios");
|
|
|
9
9
|
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
10
10
|
var _injectCIOPodfileCode = require("../helpers/utils/injectCIOPodfileCode");
|
|
11
11
|
var _fileManagement = require("./../helpers/utils/fileManagement");
|
|
12
|
+
var _utils = require("./utils");
|
|
12
13
|
const PLIST_FILENAME = `${_ios.CIO_NOTIFICATION_TARGET_NAME}-Info.plist`;
|
|
13
14
|
const ENV_FILENAME = 'Env.swift';
|
|
14
15
|
const TARGETED_DEVICE_FAMILY = `"1,2"`;
|
|
@@ -90,7 +91,8 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
90
91
|
iosDeploymentTarget,
|
|
91
92
|
useFrameworks
|
|
92
93
|
} = options;
|
|
93
|
-
|
|
94
|
+
const isFcmProvider = (0, _utils.isFcmPushProvider)(options);
|
|
95
|
+
await (0, _injectCIOPodfileCode.injectCIONotificationPodfileCode)(iosPath, useFrameworks, isFcmProvider);
|
|
94
96
|
|
|
95
97
|
// Check if `CIO_NOTIFICATION_TARGET_NAME` group already exist in the project
|
|
96
98
|
// If true then skip creating a new group to avoid duplicate folders
|
|
@@ -102,11 +104,19 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
102
104
|
_fileManagement.FileManagement.mkdir(nsePath, {
|
|
103
105
|
recursive: true
|
|
104
106
|
});
|
|
105
|
-
const
|
|
107
|
+
const platformSpecificFiles = ['NotificationService.swift'];
|
|
108
|
+
const commonFiles = [PLIST_FILENAME, 'NotificationService.h', 'NotificationService.m', ENV_FILENAME];
|
|
106
109
|
const getTargetFile = filename => `${nsePath}/${filename}`;
|
|
107
|
-
|
|
110
|
+
// Copy platform-specific files
|
|
111
|
+
platformSpecificFiles.forEach(filename => {
|
|
108
112
|
const targetFile = getTargetFile(filename);
|
|
109
|
-
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${filename}`, targetFile);
|
|
113
|
+
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${isFcmProvider ? "fcm" : "apn"}/${filename}`, targetFile);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Copy common files
|
|
117
|
+
commonFiles.forEach(filename => {
|
|
118
|
+
const targetFile = getTargetFile(filename);
|
|
119
|
+
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/common/${filename}`, targetFile);
|
|
110
120
|
});
|
|
111
121
|
|
|
112
122
|
/* MODIFY COPIED EXTENSION FILES */
|
|
@@ -119,7 +129,9 @@ const addRichPushXcodeProj = async (options, xcodeProject) => {
|
|
|
119
129
|
updateNseEnv(options, getTargetFile(ENV_FILENAME));
|
|
120
130
|
|
|
121
131
|
// Create new PBXGroup for the extension
|
|
122
|
-
const extGroup = xcodeProject.addPbxGroup(
|
|
132
|
+
const extGroup = xcodeProject.addPbxGroup([...platformSpecificFiles, ...commonFiles],
|
|
133
|
+
// Combine platform-specific and common files,
|
|
134
|
+
_ios.CIO_NOTIFICATION_TARGET_NAME, _ios.CIO_NOTIFICATION_TARGET_NAME);
|
|
123
135
|
|
|
124
136
|
// Add the new PBXGroup to the top level group. This makes the
|
|
125
137
|
// files / folder appear in the file explorer in Xcode.
|
|
@@ -207,24 +219,28 @@ const updateNseEnv = (options, envFileName) => {
|
|
|
207
219
|
_fileManagement.FileManagement.writeFile(envFileName, envFileContent);
|
|
208
220
|
};
|
|
209
221
|
async function addPushNotificationFile(options, xcodeProject) {
|
|
222
|
+
// Maybe copy a different file with FCM config based on config
|
|
210
223
|
const {
|
|
211
224
|
iosPath,
|
|
212
225
|
appName
|
|
213
226
|
} = options;
|
|
214
|
-
const
|
|
227
|
+
const isFcmProvider = (0, _utils.isFcmPushProvider)(options);
|
|
228
|
+
// PushService.swift is platform-specific and always lives in the platform folder
|
|
229
|
+
const sourceFile = `${isFcmProvider ? "fcm" : "apn"}/PushService.swift`;
|
|
230
|
+
const targetFileName = 'PushService.swift';
|
|
215
231
|
const appPath = `${iosPath}/${appName}`;
|
|
216
232
|
const getTargetFile = filename => `${appPath}/${filename}`;
|
|
217
|
-
const targetFile = getTargetFile(
|
|
233
|
+
const targetFile = getTargetFile(targetFileName);
|
|
218
234
|
|
|
219
235
|
// Check whether {file} exists in the project. If false, then add the file
|
|
220
236
|
// If {file} exists then skip and return
|
|
221
|
-
if (!_fileManagement.FileManagement.exists(getTargetFile(
|
|
237
|
+
if (!_fileManagement.FileManagement.exists(getTargetFile(targetFileName))) {
|
|
222
238
|
_fileManagement.FileManagement.mkdir(appPath, {
|
|
223
239
|
recursive: true
|
|
224
240
|
});
|
|
225
|
-
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${
|
|
241
|
+
_fileManagement.FileManagement.copyFile(`${_ios.LOCAL_PATH_TO_CIO_NSE_FILES}/${sourceFile}`, targetFile);
|
|
226
242
|
} else {
|
|
227
|
-
console.log(`${getTargetFile(
|
|
243
|
+
console.log(`${getTargetFile(targetFileName)} already exists. Skipping...`);
|
|
228
244
|
return;
|
|
229
245
|
}
|
|
230
246
|
updatePushFile(options, targetFile);
|
|
@@ -233,7 +249,7 @@ async function addPushNotificationFile(options, xcodeProject) {
|
|
|
233
249
|
name: `${appName}`
|
|
234
250
|
});
|
|
235
251
|
xcodeProject.addToPbxGroup(group, classesKey);
|
|
236
|
-
xcodeProject.addSourceFile(`${appName}/${
|
|
252
|
+
xcodeProject.addSourceFile(`${appName}/${targetFileName}`, null, group);
|
|
237
253
|
}
|
|
238
254
|
const updatePushFile = (options, envFileName) => {
|
|
239
255
|
const REGISTER_RE = /\{\{REGISTER_SNIPPET\}\}/;
|
|
@@ -249,6 +265,8 @@ const updatePushFile = (options, envFileName) => {
|
|
|
249
265
|
}
|
|
250
266
|
const autoTrackPushEvents = options.autoTrackPushEvents === undefined || options.autoTrackPushEvents === true;
|
|
251
267
|
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{AUTO_TRACK_PUSH_EVENTS\}\}/, autoTrackPushEvents.toString());
|
|
268
|
+
const autoFetchDeviceToken = options.autoFetchDeviceToken === undefined || options.autoFetchDeviceToken === true;
|
|
269
|
+
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{AUTO_FETCH_DEVICE_TOKEN\}\}/, autoFetchDeviceToken.toString());
|
|
252
270
|
const showPushAppInForeground = options.showPushAppInForeground === undefined || options.showPushAppInForeground === true;
|
|
253
271
|
envFileContent = (0, _codeInjection.replaceCodeByRegex)(envFileContent, /\{\{SHOW_PUSH_APP_IN_FOREGROUND\}\}/, showPushAppInForeground.toString());
|
|
254
272
|
_fileManagement.FileManagement.writeFile(envFileName, envFileContent);
|