@dashx/react-native 0.1.19 → 0.1.20

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/DashX.podspec CHANGED
@@ -23,8 +23,5 @@ Pod::Spec.new do |s|
23
23
 
24
24
  s.dependency "React"
25
25
  s.dependency "Apollo"
26
- s.dependency "FirebaseInstanceID"
27
- s.dependency "Firebase/Messaging"
28
- # ...
29
- # s.dependency "..."
26
+ s.dependency "FirebaseMessaging"
30
27
  end
package/README.md CHANGED
@@ -49,15 +49,19 @@ apply plugin: 'com.google.gms.google-services'
49
49
 
50
50
  ### Setup for iOS
51
51
 
52
- - At the top of the file `/ios/{projectName}/AppDelegate.m` import Firebase:
52
+ - At the top of the file `/ios/{projectName}/AppDelegate.m` before [#if defined(FB_SONARKIT_ENABLED)](https://github.com/react-native-camera/react-native-camera/issues/3008#issuecomment-726432198), import Firebase:
53
53
 
54
54
  ```objective-c
55
- #import <Firebase.h>
55
+ #import <FirebaseCore/FirebaseCore.h>
56
+ #import <FirebaseMessaging/FirebaseMessaging.h>
56
57
  ```
57
58
 
58
59
  - In the same file, inside your `didFinishLaunchingWithOptions` add this:
59
60
 
60
61
  ```objective-c
62
+ // Register for remote notifications. This shows a permission dialog on first run, to
63
+ // show the dialog at a more appropriate time move this registration accordingly.
64
+ // [START register_for_notifications]
61
65
  [UNUserNotificationCenter currentNotificationCenter].delegate = self;
62
66
  UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
63
67
  UNAuthorizationOptionSound | UNAuthorizationOptionBadge;
@@ -67,18 +71,23 @@ UNAuthorizationOptions authOptions = UNAuthorizationOptionAlert |
67
71
  }];
68
72
 
69
73
  [application registerForRemoteNotifications];
74
+ // [END register_for_notifications]
70
75
 
76
+ // [START configure_firebase]
71
77
  if ([FIRApp defaultApp] == nil) {
72
78
  [FIRApp configure];
73
79
  }
80
+ // [END configure_firebase]
74
81
 
82
+ // [START set_messaging_delegate]
75
83
  [FIRMessaging messaging].delegate = self;
84
+ // [END set_messaging_delegate]
76
85
  ```
77
86
 
78
87
  - In your `Podfile` add this:
79
88
 
80
89
  ```ruby
81
- pod 'FirebaseInstanceID', :modular_headers => true
90
+ pod 'FirebaseMessaging', :modular_headers => true
82
91
  ```
83
92
 
84
93
  - Add your iOS app on Firebase Console: `Project Overview > Add App > iOS`
package/ios/DashX.swift CHANGED
@@ -1,5 +1,5 @@
1
1
  import Foundation
2
- import FirebaseInstanceID
2
+ import FirebaseMessaging
3
3
 
4
4
  @objc(DashX)
5
5
  class DashX: RCTEventEmitter {
@@ -45,12 +45,13 @@ class DashX: RCTEventEmitter {
45
45
  UIViewController.swizzle()
46
46
  }
47
47
 
48
- InstanceID.instanceID().instanceID { (result, error) in
48
+ // Based on https://firebase.google.com/docs/cloud-messaging/ios/client#access_the_registration_token
49
+ Messaging.messaging().token { token, error in
49
50
  if let error = error {
50
- DashXLog.d(tag: #function, "Error fetching remote instance ID: \(error)")
51
- } else if let result = result {
52
- DashXLog.d(tag: #function, "Firebase initialised with: \(result.token)")
53
- self.dashXClient.setDeviceToken(to: result.token)
51
+ DashXLog.d(tag: #function, "Error fetching FCM registration token: \(error)")
52
+ } else if let token = token {
53
+ DashXLog.d(tag: #function, "Firebase initialised with: \(token)")
54
+ self.dashXClient.setDeviceToken(to: token)
54
55
  }
55
56
  }
56
57
  }
@@ -145,5 +146,4 @@ class DashX: RCTEventEmitter {
145
146
  func subscribe() {
146
147
  dashXClient.subscribe()
147
148
  }
148
-
149
149
  }
@@ -3,22 +3,26 @@ import Foundation
3
3
  @objc(DashXAppDelegate)
4
4
  class DashXAppDelegate: NSObject {
5
5
  static func swizzleDidReceiveRemoteNotificationFetchCompletionHandler() {
6
- let appDelegate = UIApplication.shared.delegate
7
- let appDelegateClass: AnyClass? = object_getClass(appDelegate)
6
+ // To remove the warning -[UIApplication delegate] must be called from main thread only
7
+ // and to call the UI controlling method from the main thread, use `DispatchQueue.main.async`
8
+ DispatchQueue.main.async {
9
+ let appDelegate = UIApplication.shared.delegate
10
+ let appDelegateClass: AnyClass? = object_getClass(appDelegate)
8
11
 
9
- let originalSelector = #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:))
10
- let swizzledSelector = #selector(DashXAppDelegate.self.handleMessage(_:didReceiveRemoteNotification:fetchCompletionHandler:))
12
+ let originalSelector = #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:))
13
+ let swizzledSelector = #selector(DashXAppDelegate.self.handleMessage(_:didReceiveRemoteNotification:fetchCompletionHandler:))
11
14
 
12
- guard let swizzledMethod = class_getInstanceMethod(DashXAppDelegate.self, swizzledSelector) else {
13
- return
14
- }
15
+ guard let swizzledMethod = class_getInstanceMethod(DashXAppDelegate.self, swizzledSelector) else {
16
+ return
17
+ }
15
18
 
16
- if let originalMethod = class_getInstanceMethod(appDelegateClass, originalSelector) {
17
- // exchange implementation
18
- method_exchangeImplementations(originalMethod, swizzledMethod)
19
- } else {
20
- // add implementation
21
- class_addMethod(appDelegateClass, swizzledSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
19
+ if let originalMethod = class_getInstanceMethod(appDelegateClass, originalSelector) {
20
+ // exchange implementation
21
+ method_exchangeImplementations(originalMethod, swizzledMethod)
22
+ } else {
23
+ // add implementation
24
+ class_addMethod(appDelegateClass, swizzledSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))
25
+ }
22
26
  }
23
27
  }
24
28
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dashx/react-native",
3
3
  "title": "DashX React Native",
4
- "version": "0.1.19",
4
+ "version": "0.1.20",
5
5
  "description": "DashX SDK for React Native",
6
6
  "main": "index.js",
7
7
  "files": [