customerio-expo-plugin 1.0.0-beta.9 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/package.json +32 -24
- package/plugin/app.plugin.js +1 -0
- package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withCIOAndroid.js +2 -0
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/commonjs/android/withProjectStrings.js +70 -0
- package/plugin/lib/commonjs/android/withProjectStrings.js.map +1 -0
- package/plugin/lib/commonjs/helpers/constants/android.js +14 -0
- package/{lib → plugin/lib}/commonjs/helpers/constants/android.js.map +1 -1
- package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js.map +1 -1
- package/plugin/lib/commonjs/helpers/constants/ios.js +119 -0
- package/plugin/lib/commonjs/helpers/constants/ios.js.map +1 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +25 -0
- package/{src/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/apn}/PushService.swift +11 -13
- package/plugin/lib/commonjs/helpers/native-files/ios/common/Env.swift +7 -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/{lib → plugin/lib}/commonjs/helpers/utils/codeInjection.js +9 -1
- package/plugin/lib/commonjs/helpers/utils/codeInjection.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +50 -0
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js +26 -0
- package/plugin/lib/commonjs/helpers/utils/pluginUtils.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/index.js +1 -2
- package/{lib → plugin/lib}/commonjs/index.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 +151 -0
- package/plugin/lib/commonjs/ios/withAppDelegateModifications.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/ios/withCIOIos.js +2 -0
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js +68 -0
- package/plugin/lib/commonjs/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/ios/withNotificationsXcodeProject.js +59 -45
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/ios/withXcodeProject.js +2 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/commonjs/postInstall.js.map +1 -1
- package/plugin/lib/commonjs/postInstallHelper.js +22 -0
- package/plugin/lib/commonjs/postInstallHelper.js.map +1 -0
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -0
- package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withAppGoogleServices.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withCIOAndroid.js +2 -0
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -0
- package/{lib → plugin/lib}/module/android/withGistMavenRepository.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js.map +1 -1
- package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js.map +1 -1
- package/plugin/lib/module/android/withProjectStrings.js +63 -0
- package/plugin/lib/module/android/withProjectStrings.js.map +1 -0
- package/{lib → plugin/lib}/module/helpers/constants/android.js.map +1 -1
- package/{lib → plugin/lib}/module/helpers/constants/globals.d.js.map +1 -1
- package/plugin/lib/module/helpers/constants/ios.js +112 -0
- package/plugin/lib/module/helpers/constants/ios.js.map +1 -0
- package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +25 -0
- package/{lib/commonjs/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/apn}/PushService.swift +11 -13
- package/plugin/lib/module/helpers/native-files/ios/common/Env.swift +7 -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/{lib → plugin/lib}/module/helpers/utils/codeInjection.js +7 -1
- package/plugin/lib/module/helpers/utils/codeInjection.js.map +1 -0
- package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js.map +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +43 -0
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -0
- package/plugin/lib/module/helpers/utils/pluginUtils.js +19 -0
- package/plugin/lib/module/helpers/utils/pluginUtils.js.map +1 -0
- package/{lib → plugin/lib}/module/index.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 +144 -0
- package/plugin/lib/module/ios/withAppDelegateModifications.js.map +1 -0
- package/{lib → plugin/lib}/module/ios/withCIOIos.js +2 -0
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js +61 -0
- package/plugin/lib/module/ios/withGoogleServicesJsonFile.js.map +1 -0
- package/{lib → plugin/lib}/module/ios/withNotificationsXcodeProject.js +59 -44
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/module/ios/withXcodeProject.js +2 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -0
- package/{lib → plugin/lib}/module/postInstall.js.map +1 -1
- package/plugin/lib/module/postInstallHelper.js +20 -0
- package/plugin/lib/module/postInstallHelper.js.map +1 -0
- package/plugin/lib/module/types/cio-types.js.map +1 -0
- package/plugin/lib/typescript/android/withProjectStrings.d.ts +15 -0
- package/plugin/lib/typescript/helpers/constants/ios.d.ts +30 -0
- package/{lib → plugin/lib}/typescript/helpers/utils/codeInjection.d.ts +3 -1
- package/{lib → plugin/lib}/typescript/helpers/utils/injectCIOPodfileCode.d.ts +2 -2
- package/plugin/lib/typescript/helpers/utils/pluginUtils.d.ts +4 -0
- package/plugin/lib/typescript/ios/utils.d.ts +7 -0
- package/plugin/lib/typescript/ios/withGoogleServicesJsonFile.d.ts +3 -0
- package/{lib → plugin/lib}/typescript/types/cio-types.d.ts +11 -2
- package/{src → plugin/src}/android/withCIOAndroid.ts +2 -0
- package/plugin/src/android/withProjectStrings.ts +57 -0
- package/plugin/src/helpers/constants/ios.ts +144 -0
- package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +25 -0
- package/{lib/module/helpers/native-files/ios → plugin/src/helpers/native-files/ios/apn}/PushService.swift +11 -13
- package/plugin/src/helpers/native-files/ios/common/Env.swift +7 -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/{src → plugin/src}/helpers/utils/codeInjection.ts +12 -1
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +68 -0
- package/plugin/src/helpers/utils/pluginUtils.ts +22 -0
- package/plugin/src/ios/utils.ts +10 -0
- package/{src → plugin/src}/ios/withAppDelegateModifications.ts +133 -23
- package/{src → plugin/src}/ios/withCIOIos.ts +2 -0
- package/plugin/src/ios/withGoogleServicesJsonFile.ts +97 -0
- package/{src → plugin/src}/ios/withNotificationsXcodeProject.ts +97 -47
- package/{src → plugin/src}/ios/withXcodeProject.ts +2 -1
- package/plugin/src/postInstallHelper.js +32 -0
- package/{src → plugin/src}/types/cio-types.ts +11 -2
- package/lib/commonjs/android/withCIOAndroid.js.map +0 -1
- package/lib/commonjs/helpers/constants/android.js +0 -21
- package/lib/commonjs/helpers/constants/ios.js +0 -121
- package/lib/commonjs/helpers/constants/ios.js.map +0 -1
- package/lib/commonjs/helpers/native-files/ios/Env.swift +0 -8
- package/lib/commonjs/helpers/native-files/ios/NotificationService.swift +0 -22
- package/lib/commonjs/helpers/utils/codeInjection.js.map +0 -1
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +0 -36
- package/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +0 -1
- package/lib/commonjs/ios/withAppDelegateModifications.js +0 -89
- package/lib/commonjs/ios/withAppDelegateModifications.js.map +0 -1
- package/lib/commonjs/ios/withCIOIos.js.map +0 -1
- package/lib/commonjs/ios/withNotificationsXcodeProject.js.map +0 -1
- package/lib/commonjs/ios/withXcodeProject.js.map +0 -1
- package/lib/commonjs/postInstallHelper.js +0 -20
- package/lib/commonjs/postInstallHelper.js.map +0 -1
- package/lib/commonjs/types/cio-types.js.map +0 -1
- package/lib/module/android/withCIOAndroid.js.map +0 -1
- package/lib/module/helpers/constants/ios.js +0 -84
- package/lib/module/helpers/constants/ios.js.map +0 -1
- package/lib/module/helpers/native-files/ios/Env.swift +0 -8
- package/lib/module/helpers/native-files/ios/NotificationService.swift +0 -22
- package/lib/module/helpers/utils/codeInjection.js.map +0 -1
- package/lib/module/helpers/utils/injectCIOPodfileCode.js +0 -29
- package/lib/module/helpers/utils/injectCIOPodfileCode.js.map +0 -1
- package/lib/module/ios/withAppDelegateModifications.js +0 -82
- package/lib/module/ios/withAppDelegateModifications.js.map +0 -1
- package/lib/module/ios/withCIOIos.js.map +0 -1
- package/lib/module/ios/withNotificationsXcodeProject.js.map +0 -1
- package/lib/module/ios/withXcodeProject.js.map +0 -1
- package/lib/module/postInstallHelper.js +0 -18
- package/lib/module/postInstallHelper.js.map +0 -1
- package/lib/module/types/cio-types.js.map +0 -1
- package/lib/typescript/helpers/constants/ios.d.ts +0 -31
- package/src/helpers/constants/ios.ts +0 -104
- package/src/helpers/native-files/ios/Env.swift +0 -8
- package/src/helpers/native-files/ios/NotificationService.swift +0 -22
- package/src/helpers/utils/injectCIOPodfileCode.ts +0 -54
- package/src/postInstallHelper.js +0 -22
- /package/{lib → plugin/lib}/commonjs/android/withAndroidManifestUpdates.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withAppGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withGistMavenRepository.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withGoogleServicesJSON.js +0 -0
- /package/{lib → plugin/lib}/commonjs/android/withProjectGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/constants/globals.d.js +0 -0
- /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
- /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService.h +0 -0
- /package/{lib/commonjs/helpers/native-files/ios → plugin/lib/commonjs/helpers/native-files/ios/common}/NotificationService.m +0 -0
- /package/{lib → plugin/lib}/commonjs/helpers/utils/fileManagement.js +0 -0
- /package/{lib → plugin/lib}/commonjs/postInstall.js +0 -0
- /package/{lib → plugin/lib}/commonjs/types/cio-types.js +0 -0
- /package/{lib → plugin/lib}/module/android/withAndroidManifestUpdates.js +0 -0
- /package/{lib → plugin/lib}/module/android/withAppGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/module/android/withGistMavenRepository.js +0 -0
- /package/{lib → plugin/lib}/module/android/withGoogleServicesJSON.js +0 -0
- /package/{lib → plugin/lib}/module/android/withProjectGoogleServices.js +0 -0
- /package/{lib → plugin/lib}/module/helpers/constants/android.js +0 -0
- /package/{lib → plugin/lib}/module/helpers/constants/globals.d.js +0 -0
- /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
- /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService.h +0 -0
- /package/{lib/module/helpers/native-files/ios → plugin/lib/module/helpers/native-files/ios/common}/NotificationService.m +0 -0
- /package/{lib → plugin/lib}/module/helpers/utils/fileManagement.js +0 -0
- /package/{lib → plugin/lib}/module/index.js +0 -0
- /package/{lib → plugin/lib}/module/postInstall.js +0 -0
- /package/{lib → plugin/lib}/module/types/cio-types.js +0 -0
- /package/{lib → plugin/lib}/typescript/android/withAndroidManifestUpdates.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withAppGoogleServices.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withCIOAndroid.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withGistMavenRepository.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withGoogleServicesJSON.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/android/withProjectGoogleServices.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/helpers/constants/android.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/helpers/utils/fileManagement.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/index.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withAppDelegateModifications.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withCIOIos.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withNotificationsXcodeProject.d.ts +0 -0
- /package/{lib → plugin/lib}/typescript/ios/withXcodeProject.d.ts +0 -0
- /package/{src → plugin/src}/android/withAndroidManifestUpdates.ts +0 -0
- /package/{src → plugin/src}/android/withAppGoogleServices.ts +0 -0
- /package/{src → plugin/src}/android/withGistMavenRepository.ts +0 -0
- /package/{src → plugin/src}/android/withGoogleServicesJSON.ts +0 -0
- /package/{src → plugin/src}/android/withProjectGoogleServices.ts +0 -0
- /package/{src → plugin/src}/helpers/constants/android.ts +0 -0
- /package/{src → plugin/src}/helpers/constants/globals.d.ts +0 -0
- /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService-Info.plist +0 -0
- /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService.h +0 -0
- /package/{src/helpers/native-files/ios → plugin/src/helpers/native-files/ios/common}/NotificationService.m +0 -0
- /package/{src → plugin/src}/helpers/utils/fileManagement.ts +0 -0
- /package/{src → plugin/src}/index.ts +0 -0
- /package/{src → plugin/src}/postInstall.js +0 -0
|
@@ -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
|
+
}
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.injectCodeBeforeMultiLineRegex = injectCodeBeforeMultiLineRegex;
|
|
6
7
|
exports.injectCodeByLineNumber = injectCodeByLineNumber;
|
|
7
8
|
exports.injectCodeByMultiLineRegex = injectCodeByMultiLineRegex;
|
|
8
9
|
exports.injectCodeByMultiLineRegexAndReplaceLine = injectCodeByMultiLineRegexAndReplaceLine;
|
|
9
10
|
exports.injectCodeByRegex = injectCodeByRegex;
|
|
11
|
+
exports.matchRegexExists = matchRegexExists;
|
|
10
12
|
exports.replaceCodeByRegex = replaceCodeByRegex;
|
|
11
13
|
function injectCodeByRegex(fileContent, lineRegex, snippet) {
|
|
12
14
|
const lines = fileContent.split('\n');
|
|
@@ -20,9 +22,15 @@ function injectCodeByRegex(fileContent, lineRegex, snippet) {
|
|
|
20
22
|
function injectCodeByMultiLineRegex(fileContent, lineRegex, snippet) {
|
|
21
23
|
return fileContent.replace(lineRegex, `$&\n${snippet}`);
|
|
22
24
|
}
|
|
25
|
+
function injectCodeBeforeMultiLineRegex(fileContent, lineRegex, snippet) {
|
|
26
|
+
return fileContent.replace(lineRegex, `${snippet}\n$&`);
|
|
27
|
+
}
|
|
23
28
|
function replaceCodeByRegex(fileContent, lineRegex, snippet) {
|
|
24
29
|
return fileContent.replace(lineRegex, snippet);
|
|
25
30
|
}
|
|
31
|
+
function matchRegexExists(fileContent, regex) {
|
|
32
|
+
return regex.test(fileContent);
|
|
33
|
+
}
|
|
26
34
|
function injectCodeByMultiLineRegexAndReplaceLine(fileContent, lineRegex, snippet) {
|
|
27
35
|
return fileContent.replace(lineRegex, `${snippet}`);
|
|
28
36
|
}
|
|
@@ -32,6 +40,6 @@ function injectCodeByLineNumber(fileContent, index, snippet) {
|
|
|
32
40
|
if (index > -1) {
|
|
33
41
|
content = [...lines.slice(0, index), snippet, ...lines.slice(index)];
|
|
34
42
|
}
|
|
35
|
-
return content;
|
|
43
|
+
return content.join('\n');
|
|
36
44
|
}
|
|
37
45
|
//# sourceMappingURL=codeInjection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["injectCodeByRegex","fileContent","lineRegex","snippet","lines","split","index","findIndex","line","test","content","slice","injectCodeByMultiLineRegex","replace","injectCodeBeforeMultiLineRegex","replaceCodeByRegex","matchRegexExists","regex","injectCodeByMultiLineRegexAndReplaceLine","injectCodeByLineNumber","join"],"sources":["codeInjection.ts"],"sourcesContent":["export function injectCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n const index = lines.findIndex((line) => lineRegex.test(line));\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content;\n}\n\nexport function injectCodeByMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `$&\\n${snippet}`);\n}\n\nexport function injectCodeBeforeMultiLineRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}\\n$&`);\n}\n\nexport function replaceCodeByRegex(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, snippet);\n}\n\nexport function matchRegexExists(fileContent: string, regex: RegExp) {\n return regex.test(fileContent);\n}\nexport function injectCodeByMultiLineRegexAndReplaceLine(\n fileContent: string,\n lineRegex: RegExp,\n snippet: string\n) {\n return fileContent.replace(lineRegex, `${snippet}`);\n}\n\nexport function injectCodeByLineNumber(\n fileContent: string,\n index: number,\n snippet: string\n) {\n const lines = fileContent.split('\\n');\n let content: string[] = lines;\n\n if (index > -1) {\n content = [...lines.slice(0, index), snippet, ...lines.slice(index)];\n }\n\n return content.join('\\n');\n}\n"],"mappings":";;;;;;;;;;;;AAAO,SAASA,iBAAiBA,CAC/BC,WAAmB,EACnBC,SAAiB,EACjBC,OAAe,EACf;EACA,MAAMC,KAAK,GAAGH,WAAW,CAACI,KAAK,CAAC,IAAI,CAAC;EACrC,MAAMC,KAAK,GAAGF,KAAK,CAACG,SAAS,CAAEC,IAAI,IAAKN,SAAS,CAACO,IAAI,CAACD,IAAI,CAAC,CAAC;EAC7D,IAAIE,OAAiB,GAAGN,KAAK;EAE7B,IAAIE,KAAK,GAAG,CAAC,CAAC,EAAE;IACdI,OAAO,GAAG,CAAC,GAAGN,KAAK,CAACO,KAAK,CAAC,CAAC,EAAEL,KAAK,CAA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@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_fs","require","FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","console","log","mkdir","options","mkdirSync","writeFileSync","readFileSync","exports"],"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,IAAAA,GAAA,GAAAC,OAAA;AAYO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAIA,CAACC,IAAY,EAAmB;IAC/C,O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"version":3,"names":["_fs","require","FileManagement","read","path","Promise","resolve","reject","readFile","err","data","write","contents","writeFile","append","appendFile","exists","existsSync","copyFile","src","dest","copyFileSync","console","log","mkdir","options","mkdirSync","writeFileSync","readFileSync","exports"],"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,IAAAA,GAAA,GAAAC,OAAA;AAYO,MAAMC,cAAc,CAAC;EAC1B,aAAaC,IAAIA,CAACC,IAAY,EAAmB;IAC/C,OAAO,IAAIC,OAAO,CAAS,CAACC,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AEX,GAAG,CAAC;IACjE;EACF;EAEA,OAAOe,KAAKA,CAACpB,IAAY,EAAEqB,OAA6B,EAAE;IACxD,IAAI;MACF,IAAAC,aAAS,EAACtB,IAAI,EAAEqB,OAAO,CAAC;IAC1B,CAAC,CAAC,OAAOhB,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAC,4BAA4BnB,IAAI,IAAI,EAAEK,GAAG,CAAC;IACxD;EACF;EAEA,OAAOI,SAASA,CAACT,IAAY,EAAEM,IAAY,EAAE;IAC3C,IAAI;MACF,IAAAiB,iBAAa,EAACvB,IAAI,EAAEM,IAAI,CAAC;IAC3B,CAAC,CAAC,OAAOD,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAC,yBAAyBnB,IAAI,IAAI,EAAEK,GAAG,CAAC;IACrD;EACF;EAEA,OAAOD,QAAQA,CAACJ,IAAY,EAAE;IAC5B,IAAI;MACF,OAAO,IAAAwB,gBAAY,EAACxB,IAAI,EAAE,OAAO,CAAC;IACpC,CAAC,CAAC,OAAOK,GAAG,EAAE;MACZa,OAAO,CAACC,GAAG,CAAC,sBAAsBnB,IAAI,IAAI,EAAEK,GAAG,CAAC;IAClD;IAEA,OAAO,EAAE;EACX;AACF;AAACoB,OAAA,CAAA3B,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
|
|
7
|
+
exports.injectCIOPodfileCode = injectCIOPodfileCode;
|
|
8
|
+
var _ios = require("../constants/ios");
|
|
9
|
+
var _codeInjection = require("./codeInjection");
|
|
10
|
+
var _fileManagement = require("./fileManagement");
|
|
11
|
+
async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
|
|
12
|
+
const blockStart = '# --- CustomerIO Host App START ---';
|
|
13
|
+
const blockEnd = '# --- CustomerIO Host App END ---';
|
|
14
|
+
const filename = `${iosPath}/Podfile`;
|
|
15
|
+
const podfile = await _fileManagement.FileManagement.read(filename);
|
|
16
|
+
const matches = podfile.match(new RegExp(blockStart));
|
|
17
|
+
if (!matches) {
|
|
18
|
+
// We need to decide what line of code in the Podfile to insert our native code.
|
|
19
|
+
// The "post_install" line is always present in an Expo project Podfile so it's reliable.
|
|
20
|
+
// Find that line in the Podfile and then we will insert our code above that line.
|
|
21
|
+
const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
|
|
22
|
+
const snippetToInjectInPodfile = `
|
|
23
|
+
${blockStart}
|
|
24
|
+
pod 'customerio-reactnative/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${(0, _ios.getRelativePathToRNSDK)(iosPath)}'
|
|
25
|
+
${blockEnd}
|
|
26
|
+
`.trim();
|
|
27
|
+
_fileManagement.FileManagement.write(filename, (0, _codeInjection.injectCodeByRegex)(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
28
|
+
} else {
|
|
29
|
+
console.log('CustomerIO Podfile snippets already exists. Skipping...');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function injectCIONotificationPodfileCode(iosPath, useFrameworks, isFcmPushProvider) {
|
|
33
|
+
const filename = `${iosPath}/Podfile`;
|
|
34
|
+
const podfile = await _fileManagement.FileManagement.read(filename);
|
|
35
|
+
const blockStart = '# --- CustomerIO Notification START ---';
|
|
36
|
+
const blockEnd = '# --- CustomerIO Notification END ---';
|
|
37
|
+
const matches = podfile.match(new RegExp(blockStart));
|
|
38
|
+
if (!matches) {
|
|
39
|
+
const snippetToInjectInPodfile = `
|
|
40
|
+
${blockStart}
|
|
41
|
+
target 'NotificationService' do
|
|
42
|
+
${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}
|
|
43
|
+
pod 'customerio-reactnative-richpush/${isFcmPushProvider ? "fcm" : "apn"}', :path => '${(0, _ios.getRelativePathToRNSDK)(iosPath)}'
|
|
44
|
+
end
|
|
45
|
+
${blockEnd}
|
|
46
|
+
`.trim();
|
|
47
|
+
_fileManagement.FileManagement.append(filename, snippetToInjectInPodfile);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=injectCIOPodfileCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPluginVersion = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/**
|
|
11
|
+
* Reads the version of the plugin from its `package.json` and returns it as a string.
|
|
12
|
+
*/
|
|
13
|
+
const getPluginVersion = () => {
|
|
14
|
+
// Always resolves relative to the utility file's location
|
|
15
|
+
const packageJsonPath = _path.default.resolve(__dirname, '../../../../../package.json');
|
|
16
|
+
if (!_fs.default.existsSync(packageJsonPath)) {
|
|
17
|
+
throw new Error(`package.json not found at ${packageJsonPath}`);
|
|
18
|
+
}
|
|
19
|
+
const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf8'));
|
|
20
|
+
if (!packageJson.version) {
|
|
21
|
+
throw new Error(`"version" field is missing in ${packageJsonPath}`);
|
|
22
|
+
}
|
|
23
|
+
return packageJson.version;
|
|
24
|
+
};
|
|
25
|
+
exports.getPluginVersion = getPluginVersion;
|
|
26
|
+
//# sourceMappingURL=pluginUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_fs","_interopRequireDefault","require","_path","e","__esModule","default","getPluginVersion","packageJsonPath","path","resolve","__dirname","fs","existsSync","Error","packageJson","JSON","parse","readFileSync","version","exports"],"sources":["pluginUtils.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\n/**\n * Reads the version of the plugin from its `package.json` and returns it as a string.\n */\nexport const getPluginVersion = (): string => {\n // Always resolves relative to the utility file's location\n const packageJsonPath = path.resolve(__dirname, '../../../../../package.json');\n\n if (!fs.existsSync(packageJsonPath)) {\n throw new Error(`package.json not found at ${packageJsonPath}`);\n }\n\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));\n\n if (!packageJson.version) {\n throw new Error(`\"version\" field is missing in ${packageJsonPath}`);\n }\n\n return packageJson.version;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB;AACA;AACA;AACO,MAAMG,gBAAgB,GAAGA,CAAA,KAAc;EAC5C;EACA,MAAMC,eAAe,GAAGC,aAAI,CAACC,OAAO,CAACC,SAAS,EAAE,6BAA6B,CAAC;EAE9E,IAAI,CAACC,WAAE,CAACC,UAAU,CAACL,eAAe,CAAC,EAAE;IACnC,MAAM,IAAIM,KAAK,CAAC,6BAA6BN,eAAe,EAAE,CAAC;EACjE;EAEA,MAAMO,WAAW,GAAGC,IAAI,CAACC,KAAK,CAACL,WAAE,CAACM,YAAY,CAACV,eAAe,EAAE,MAAM,CAAC,CAAC;EAExE,IAAI,CAACO,WAAW,CAACI,OAAO,EAAE;IACxB,MAAM,IAAIL,KAAK,CAAC,iCAAiCN,eAAe,EAAE,CAAC;EACrE;EAEA,OAAOO,WAAW,CAACI,OAAO;AAC5B,CAAC;AAACC,OAAA,CAAAb,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withCIOAndroid","require","_withCIOIos","withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\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 return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA;AACA,SAASE,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEA,OAAOJ,MAAM;AACf;AAAC,IAAAM,QAAA,
|
|
1
|
+
{"version":3,"names":["_withCIOAndroid","require","_withCIOIos","withCustomerIOPlugin","config","props","ios","withCIOIos","android","withCIOAndroid","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\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 return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA;AACA,SAASE,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA,IAAIA,KAAK,CAACC,GAAG,EAAE;IACbF,MAAM,GAAG,IAAAG,sBAAU,EAACH,MAAM,EAAEC,KAAK,CAACC,GAAG,CAAC;EACxC;EAEA,IAAID,KAAK,CAACG,OAAO,EAAE;IACjBJ,MAAM,GAAG,IAAAK,8BAAc,EAACL,MAAM,EAAEC,KAAK,CAACG,OAAO,CAAC;EAChD;EAEA,OAAOJ,MAAM;AACf;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcT,oBAAoB","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":[]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withAppDelegateModifications = void 0;
|
|
7
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
var _Paths = require("@expo/config-plugins/build/ios/Paths");
|
|
9
|
+
var _ios = require("../helpers/constants/ios");
|
|
10
|
+
var _codeInjection = require("../helpers/utils/codeInjection");
|
|
11
|
+
var _fileManagement = require("../helpers/utils/fileManagement");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
const addImport = (stringContents, appName) => {
|
|
14
|
+
const importRegex = /^(#import .*)\n/gm;
|
|
15
|
+
const addedImport = getImportSnippet(appName);
|
|
16
|
+
const match = stringContents.match(importRegex);
|
|
17
|
+
let endOfMatchIndex;
|
|
18
|
+
if (!match || match.index === undefined) {
|
|
19
|
+
// No imports found, just add to start of file:
|
|
20
|
+
endOfMatchIndex = 0;
|
|
21
|
+
} else {
|
|
22
|
+
// Add after first import:
|
|
23
|
+
endOfMatchIndex = match.index + match[0].length;
|
|
24
|
+
}
|
|
25
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, endOfMatchIndex, addedImport);
|
|
26
|
+
return stringContents;
|
|
27
|
+
};
|
|
28
|
+
const addNotificationHandlerDeclaration = stringContents => {
|
|
29
|
+
stringContents = (0, _codeInjection.injectCodeByMultiLineRegex)(stringContents, _ios.CIO_APPDELEGATEDECLARATION_REGEX, _ios.CIO_PUSHNOTIFICATIONHANDLERDECLARATION_SNIPPET);
|
|
30
|
+
return stringContents;
|
|
31
|
+
};
|
|
32
|
+
const addNotificationConfiguration = stringContents => {
|
|
33
|
+
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.CIO_CONFIGURECIOSDKPUSHNOTIFICATION_SNIPPET);
|
|
34
|
+
return stringContents;
|
|
35
|
+
};
|
|
36
|
+
const addInitializeNativeCioSdk = stringContents => {
|
|
37
|
+
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, _ios.CIO_DIDFINISHLAUNCHINGMETHOD_REGEX, _ios.CIO_INITIALIZECIOSDK_SNIPPET);
|
|
38
|
+
return stringContents;
|
|
39
|
+
};
|
|
40
|
+
const addHandleDeeplinkInKilledStateConfiguration = (stringContents, regex) => {
|
|
41
|
+
stringContents = (0, _codeInjection.injectCodeBeforeMultiLineRegex)(stringContents, regex, _ios.CIO_CONFIGUREDEEPLINK_KILLEDSTATE_SNIPPET);
|
|
42
|
+
return stringContents;
|
|
43
|
+
};
|
|
44
|
+
const addDidFailToRegisterForRemoteNotificationsWithError = stringContents => {
|
|
45
|
+
stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_REGEX, _ios.CIO_DIDFAILTOREGISTERFORREMOTENOTIFICATIONSWITHERROR_SNIPPET);
|
|
46
|
+
return stringContents;
|
|
47
|
+
};
|
|
48
|
+
const addDidRegisterForRemoteNotificationsWithDeviceToken = stringContents => {
|
|
49
|
+
stringContents = (0, _codeInjection.injectCodeByMultiLineRegexAndReplaceLine)(stringContents, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_REGEX, _ios.CIO_DIDREGISTERFORREMOTENOTIFICATIONSWITHDEVICETOKEN_SNIPPET);
|
|
50
|
+
return stringContents;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// Adds required import for Expo Notifications package in AppDelegate.
|
|
54
|
+
// Required to call functions from the package.
|
|
55
|
+
const addExpoNotificationsHeaderModification = stringContents => {
|
|
56
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, 0, `
|
|
57
|
+
#if __has_include(<EXNotifications/EXNotificationCenterDelegate.h>)
|
|
58
|
+
#import <EXNotifications/EXNotificationCenterDelegate.h>
|
|
59
|
+
#endif
|
|
60
|
+
`);
|
|
61
|
+
return stringContents;
|
|
62
|
+
};
|
|
63
|
+
const addFirebaseDelegateForwardDeclarationIfNeeded = stringContents => {
|
|
64
|
+
stringContents = (0, _codeInjection.injectCodeByLineNumber)(stringContents, 0, '@protocol FIRMessagingDelegate;');
|
|
65
|
+
return stringContents;
|
|
66
|
+
};
|
|
67
|
+
const addAppdelegateHeaderModification = stringContents => {
|
|
68
|
+
// Add UNUserNotificationCenterDelegate if needed
|
|
69
|
+
stringContents = stringContents.replace(_ios.CIO_APPDELEGATEHEADER_REGEX, (match, interfaceDeclaration, _groupedDelegates, existingDelegates) => {
|
|
70
|
+
if (existingDelegates && existingDelegates.includes(_ios.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET)) {
|
|
71
|
+
// The AppDelegate declaration already includes UNUserNotificationCenterDelegate, so we don't need to modify it
|
|
72
|
+
return match;
|
|
73
|
+
} else if (existingDelegates) {
|
|
74
|
+
// Other delegates exist, append ours
|
|
75
|
+
return `${_ios.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}
|
|
76
|
+
${interfaceDeclaration}<${existingDelegates}, ${_ios.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>
|
|
77
|
+
`;
|
|
78
|
+
} else {
|
|
79
|
+
// No delegates exist, add ours
|
|
80
|
+
return `${_ios.CIO_APPDELEGATEHEADER_IMPORT_SNIPPET}
|
|
81
|
+
${interfaceDeclaration.trim()} <${_ios.CIO_APPDELEGATEHEADER_USER_NOTIFICATION_CENTER_SNIPPET}>
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return stringContents;
|
|
86
|
+
};
|
|
87
|
+
const addHandleDeeplinkInKilledState = stringContents => {
|
|
88
|
+
// Find if the deep link code snippet is already present
|
|
89
|
+
if ((0, _codeInjection.matchRegexExists)(stringContents, _ios.CIO_DEEPLINK_COMMENT_REGEX)) {
|
|
90
|
+
return stringContents;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Check if the app delegate is using RCTBridge or LaunchOptions
|
|
94
|
+
let snippet = undefined;
|
|
95
|
+
let regex = _ios.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
96
|
+
if ((0, _codeInjection.matchRegexExists)(stringContents, _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
97
|
+
snippet = _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_SNIPPET;
|
|
98
|
+
regex = _ios.CIO_RCTBRIDGE_DEEPLINK_MODIFIEDOPTIONS_REGEX;
|
|
99
|
+
} else if ((0, _codeInjection.matchRegexExists)(stringContents, _ios.CIO_LAUNCHOPTIONS_DEEPLINK_MODIFIEDOPTIONS_REGEX)) {
|
|
100
|
+
snippet = _ios.CIO_LAUNCHOPTIONS_MODIFIEDOPTIONS_SNIPPET;
|
|
101
|
+
}
|
|
102
|
+
// Add code only if the app delegate is using RCTBridge or LaunchOptions
|
|
103
|
+
if (snippet !== undefined) {
|
|
104
|
+
stringContents = addHandleDeeplinkInKilledStateConfiguration(stringContents, regex);
|
|
105
|
+
stringContents = (0, _codeInjection.replaceCodeByRegex)(stringContents, regex, snippet);
|
|
106
|
+
}
|
|
107
|
+
return stringContents;
|
|
108
|
+
};
|
|
109
|
+
const withAppDelegateModifications = (configOuter, props) => {
|
|
110
|
+
return (0, _configPlugins.withAppDelegate)(configOuter, async config => {
|
|
111
|
+
let stringContents = config.modResults.contents;
|
|
112
|
+
const regex = new RegExp(`#import <${config.modRequest.projectName}-Swift.h>`);
|
|
113
|
+
const match = stringContents.match(regex);
|
|
114
|
+
if (!match) {
|
|
115
|
+
const headerPath = (0, _Paths.getAppDelegateHeaderFilePath)(config.modRequest.projectRoot);
|
|
116
|
+
let headerContent = await _fileManagement.FileManagement.read(headerPath);
|
|
117
|
+
headerContent = addAppdelegateHeaderModification(headerContent);
|
|
118
|
+
_fileManagement.FileManagement.write(headerPath, headerContent);
|
|
119
|
+
stringContents = addImport(stringContents, config.modRequest.projectName);
|
|
120
|
+
stringContents = addNotificationHandlerDeclaration(stringContents);
|
|
121
|
+
|
|
122
|
+
// any other value would be treated as true, it has to be explicitly false to disable
|
|
123
|
+
if (props.disableNotificationRegistration !== undefined && props.disableNotificationRegistration === false) {
|
|
124
|
+
stringContents = addNotificationConfiguration(stringContents);
|
|
125
|
+
}
|
|
126
|
+
stringContents = addInitializeNativeCioSdk(stringContents);
|
|
127
|
+
if (props.handleDeeplinkInKilledState !== undefined && props.handleDeeplinkInKilledState === true) {
|
|
128
|
+
stringContents = addHandleDeeplinkInKilledState(stringContents);
|
|
129
|
+
}
|
|
130
|
+
stringContents = addDidFailToRegisterForRemoteNotificationsWithError(stringContents);
|
|
131
|
+
stringContents = addDidRegisterForRemoteNotificationsWithDeviceToken(stringContents);
|
|
132
|
+
if ((0, _utils.isFcmPushProvider)(props)) {
|
|
133
|
+
stringContents = addFirebaseDelegateForwardDeclarationIfNeeded(stringContents);
|
|
134
|
+
}
|
|
135
|
+
stringContents = addExpoNotificationsHeaderModification(stringContents);
|
|
136
|
+
config.modResults.contents = stringContents;
|
|
137
|
+
} else {
|
|
138
|
+
console.log('Customerio AppDelegate changes already exist. Skipping...');
|
|
139
|
+
}
|
|
140
|
+
return config;
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
exports.withAppDelegateModifications = withAppDelegateModifications;
|
|
144
|
+
function getImportSnippet(appName) {
|
|
145
|
+
return `
|
|
146
|
+
// Add swift bridge imports
|
|
147
|
+
#import <ExpoModulesCore-Swift.h>
|
|
148
|
+
#import <${appName}-Swift.h>
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=withAppDelegateModifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,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AyB,CAACnB,cAAc,CAAC;MAE1D,IACEsD,KAAK,CAACgB,2BAA2B,KAAK9D,SAAS,IAC/C8C,KAAK,CAACgB,2BAA2B,KAAK,IAAI,EAC1C;QACAtE,cAAc,GAAG2C,8BAA8B,CAAC3C,cAAc,CAAC;MACjE;MAEAA,cAAc,GACZwB,mDAAmD,CAACxB,cAAc,CAAC;MACrEA,cAAc,GACZ4B,mDAAmD,CAAC5B,cAAc,CAAC;MAErE,IAAI,IAAAuE,wBAAiB,EAACjB,KAAK,CAAC,EAAE;QAC5BtD,cAAc,GAAGgC,6CAA6C,CAAChC,cAAc,CAAC;MAChF;MAEAA,cAAc,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
|
}
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAEC,QAAQ,KAAK;EACxB,OAAO,IAAAC,+BAAgB,EAACF,MAAM,EAAE,MAAOG,KAAK,IAAK;IAAA,IAAAC,qBAAA;IAC/C,MAAMC,MAAM,GAAG,IAAAC,wBAAiB,EAACL,QAAQ,CAAC;IAC1C,IAAI,CAACI,MAAM,EAAE;MACX;MACA,OAAOF,KAA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