customerio-expo-plugin 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customerio-expo-plugin",
3
- "version": "2.2.0",
3
+ "version": "2.3.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",
@@ -7,19 +7,15 @@ import EXNotifications
7
7
  import ExpoModulesCore
8
8
  #endif
9
9
 
10
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate {}
11
+
10
12
  public class CioSdkAppDelegateHandler: NSObject {
13
+
14
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
11
15
 
12
16
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
13
17
 
14
18
  {{REGISTER_SNIPPET}}
15
-
16
- MessagingPushAPN.initialize(
17
- withConfig: MessagingPushConfigBuilder()
18
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
19
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
20
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
21
- .build()
22
- )
23
19
 
24
20
  // Code to make the CIO SDK compatible with expo-notifications package.
25
21
  //
@@ -40,13 +36,23 @@ public class CioSdkAppDelegateHandler: NSObject {
40
36
  center.delegate = notificationCenterDelegate
41
37
  }
42
38
  #endif
39
+
40
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
41
+
42
+ MessagingPushAPN.initialize(
43
+ withConfig: MessagingPushConfigBuilder()
44
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
45
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
46
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
47
+ .build()
48
+ )
43
49
  }
44
50
 
45
51
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
46
- MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
52
+ cioAppDelegate.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
47
53
  }
48
54
 
49
55
  public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
50
- MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
56
+ cioAppDelegate.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
51
57
  }
52
58
  }
@@ -9,25 +9,17 @@ import EXNotifications
9
9
  import ExpoModulesCore
10
10
  #endif
11
11
 
12
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate, MessagingDelegate {
13
+ func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {}
14
+ }
15
+
12
16
  public class CioSdkAppDelegateHandler: NSObject {
17
+
18
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
13
19
 
14
20
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
15
21
 
16
22
  {{REGISTER_SNIPPET}}
17
-
18
- if (FirebaseApp.app() == nil) {
19
- FirebaseApp.configure()
20
- }
21
- Messaging.messaging().delegate = self
22
- UIApplication.shared.registerForRemoteNotifications()
23
-
24
- MessagingPushFCM.initialize(
25
- withConfig: MessagingPushConfigBuilder()
26
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
27
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
28
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
29
- .build()
30
- )
31
23
 
32
24
  // Code to make the CIO SDK compatible with expo-notifications package.
33
25
  //
@@ -48,6 +40,20 @@ public class CioSdkAppDelegateHandler: NSObject {
48
40
  center.delegate = notificationCenterDelegate
49
41
  }
50
42
  #endif
43
+
44
+ if (FirebaseApp.app() == nil) {
45
+ FirebaseApp.configure()
46
+ }
47
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
48
+ UIApplication.shared.registerForRemoteNotifications()
49
+
50
+ MessagingPushFCM.initialize(
51
+ withConfig: MessagingPushConfigBuilder()
52
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
53
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
54
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
55
+ .build()
56
+ )
51
57
  }
52
58
 
53
59
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
@@ -58,17 +64,3 @@ public class CioSdkAppDelegateHandler: NSObject {
58
64
 
59
65
  }
60
66
  }
61
-
62
- extension CioSdkAppDelegateHandler: MessagingDelegate {
63
- public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
64
- MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
65
- }
66
-
67
- func userNotificationCenter(
68
- _ center: UNUserNotificationCenter,
69
- willPresent notification: UNNotification,
70
- withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
71
- ) {
72
- completionHandler([.list, .banner, .badge, .sound])
73
- }
74
- }
@@ -7,19 +7,15 @@ import EXNotifications
7
7
  import ExpoModulesCore
8
8
  #endif
9
9
 
10
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate {}
11
+
10
12
  public class CioSdkAppDelegateHandler: NSObject {
13
+
14
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
11
15
 
12
16
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
13
17
 
14
18
  {{REGISTER_SNIPPET}}
15
-
16
- MessagingPushAPN.initialize(
17
- withConfig: MessagingPushConfigBuilder()
18
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
19
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
20
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
21
- .build()
22
- )
23
19
 
24
20
  // Code to make the CIO SDK compatible with expo-notifications package.
25
21
  //
@@ -40,13 +36,23 @@ public class CioSdkAppDelegateHandler: NSObject {
40
36
  center.delegate = notificationCenterDelegate
41
37
  }
42
38
  #endif
39
+
40
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
41
+
42
+ MessagingPushAPN.initialize(
43
+ withConfig: MessagingPushConfigBuilder()
44
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
45
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
46
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
47
+ .build()
48
+ )
43
49
  }
44
50
 
45
51
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
46
- MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
52
+ cioAppDelegate.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
47
53
  }
48
54
 
49
55
  public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
50
- MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
56
+ cioAppDelegate.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
51
57
  }
52
58
  }
@@ -9,25 +9,17 @@ import EXNotifications
9
9
  import ExpoModulesCore
10
10
  #endif
11
11
 
12
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate, MessagingDelegate {
13
+ func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {}
14
+ }
15
+
12
16
  public class CioSdkAppDelegateHandler: NSObject {
17
+
18
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
13
19
 
14
20
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
15
21
 
16
22
  {{REGISTER_SNIPPET}}
17
-
18
- if (FirebaseApp.app() == nil) {
19
- FirebaseApp.configure()
20
- }
21
- Messaging.messaging().delegate = self
22
- UIApplication.shared.registerForRemoteNotifications()
23
-
24
- MessagingPushFCM.initialize(
25
- withConfig: MessagingPushConfigBuilder()
26
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
27
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
28
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
29
- .build()
30
- )
31
23
 
32
24
  // Code to make the CIO SDK compatible with expo-notifications package.
33
25
  //
@@ -48,6 +40,20 @@ public class CioSdkAppDelegateHandler: NSObject {
48
40
  center.delegate = notificationCenterDelegate
49
41
  }
50
42
  #endif
43
+
44
+ if (FirebaseApp.app() == nil) {
45
+ FirebaseApp.configure()
46
+ }
47
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
48
+ UIApplication.shared.registerForRemoteNotifications()
49
+
50
+ MessagingPushFCM.initialize(
51
+ withConfig: MessagingPushConfigBuilder()
52
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
53
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
54
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
55
+ .build()
56
+ )
51
57
  }
52
58
 
53
59
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
@@ -58,17 +64,3 @@ public class CioSdkAppDelegateHandler: NSObject {
58
64
 
59
65
  }
60
66
  }
61
-
62
- extension CioSdkAppDelegateHandler: MessagingDelegate {
63
- public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
64
- MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
65
- }
66
-
67
- func userNotificationCenter(
68
- _ center: UNUserNotificationCenter,
69
- willPresent notification: UNNotification,
70
- withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
71
- ) {
72
- completionHandler([.list, .banner, .badge, .sound])
73
- }
74
- }
@@ -7,19 +7,15 @@ import EXNotifications
7
7
  import ExpoModulesCore
8
8
  #endif
9
9
 
10
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate {}
11
+
10
12
  public class CioSdkAppDelegateHandler: NSObject {
13
+
14
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
11
15
 
12
16
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
13
17
 
14
18
  {{REGISTER_SNIPPET}}
15
-
16
- MessagingPushAPN.initialize(
17
- withConfig: MessagingPushConfigBuilder()
18
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
19
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
20
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
21
- .build()
22
- )
23
19
 
24
20
  // Code to make the CIO SDK compatible with expo-notifications package.
25
21
  //
@@ -40,13 +36,23 @@ public class CioSdkAppDelegateHandler: NSObject {
40
36
  center.delegate = notificationCenterDelegate
41
37
  }
42
38
  #endif
39
+
40
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
41
+
42
+ MessagingPushAPN.initialize(
43
+ withConfig: MessagingPushConfigBuilder()
44
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
45
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
46
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
47
+ .build()
48
+ )
43
49
  }
44
50
 
45
51
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
46
- MessagingPush.shared.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
52
+ cioAppDelegate.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
47
53
  }
48
54
 
49
55
  public func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
50
- MessagingPush.shared.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
56
+ cioAppDelegate.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
51
57
  }
52
58
  }
@@ -9,25 +9,17 @@ import EXNotifications
9
9
  import ExpoModulesCore
10
10
  #endif
11
11
 
12
+ private class DummyAppDelegate: NSObject, UIApplicationDelegate, MessagingDelegate {
13
+ func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {}
14
+ }
15
+
12
16
  public class CioSdkAppDelegateHandler: NSObject {
17
+
18
+ private let cioAppDelegate = CioAppDelegateWrapper<DummyAppDelegate>()
13
19
 
14
20
  public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) {
15
21
 
16
22
  {{REGISTER_SNIPPET}}
17
-
18
- if (FirebaseApp.app() == nil) {
19
- FirebaseApp.configure()
20
- }
21
- Messaging.messaging().delegate = self
22
- UIApplication.shared.registerForRemoteNotifications()
23
-
24
- MessagingPushFCM.initialize(
25
- withConfig: MessagingPushConfigBuilder()
26
- .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
27
- .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
28
- .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
29
- .build()
30
- )
31
23
 
32
24
  // Code to make the CIO SDK compatible with expo-notifications package.
33
25
  //
@@ -48,6 +40,20 @@ public class CioSdkAppDelegateHandler: NSObject {
48
40
  center.delegate = notificationCenterDelegate
49
41
  }
50
42
  #endif
43
+
44
+ if (FirebaseApp.app() == nil) {
45
+ FirebaseApp.configure()
46
+ }
47
+ _ = cioAppDelegate.application(application, didFinishLaunchingWithOptions: launchOptions)
48
+ UIApplication.shared.registerForRemoteNotifications()
49
+
50
+ MessagingPushFCM.initialize(
51
+ withConfig: MessagingPushConfigBuilder()
52
+ .autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
53
+ .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
54
+ .autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
55
+ .build()
56
+ )
51
57
  }
52
58
 
53
59
  public func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
@@ -58,17 +64,3 @@ public class CioSdkAppDelegateHandler: NSObject {
58
64
 
59
65
  }
60
66
  }
61
-
62
- extension CioSdkAppDelegateHandler: MessagingDelegate {
63
- public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
64
- MessagingPush.shared.messaging(messaging, didReceiveRegistrationToken: fcmToken)
65
- }
66
-
67
- func userNotificationCenter(
68
- _ center: UNUserNotificationCenter,
69
- willPresent notification: UNNotification,
70
- withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
71
- ) {
72
- completionHandler([.list, .banner, .badge, .sound])
73
- }
74
- }