@dashx/react-native 0.1.13 → 0.1.14
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/ios/DashXAppDelegate.swift +18 -15
- package/package.json +1 -1
|
@@ -3,23 +3,28 @@ import Foundation
|
|
|
3
3
|
@objc(DashXAppDelegate)
|
|
4
4
|
class DashXAppDelegate: NSObject {
|
|
5
5
|
static func swizzleDidReceiveRemoteNotification() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let appDelegateClass = object_getClass(appDelegate)
|
|
6
|
+
let appDelegate = UIApplication.shared.delegate
|
|
7
|
+
let appDelegateClass = object_getClass(appDelegate)
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
DashXAppDelegate.self.handleMessage(_:didReceiveRemoteNotification:)
|
|
13
|
-
)
|
|
9
|
+
let originalSelector = #selector(UIApplicationDelegate.application(_:didReceiveRemoteNotification:fetchCompletionHandler:))
|
|
10
|
+
let swizzledSelector = #selector(DashXAppDelegate.self.handleMessage(_:didReceiveRemoteNotification:fetchCompletionHandler:))
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
guard let swizzledMethod = class_getInstanceMethod(DashXAppDelegate.self, swizzledSelector) else {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
15
|
+
|
|
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))
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
|
|
25
|
+
// Based on - https://firebase.google.com/docs/cloud-messaging/ios/receive
|
|
19
26
|
@objc
|
|
20
|
-
func handleMessage(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
|
|
21
|
-
var properties: [String: [String: Any]] = [ "notification": [:] ]
|
|
22
|
-
|
|
27
|
+
func handleMessage(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
|
|
23
28
|
DashXLog.d(tag: #function, "Received APN: \(userInfo)")
|
|
24
29
|
|
|
25
30
|
guard let remoteMessage = try? FirebaseRemoteMessage(decoding: userInfo) else {
|
|
@@ -27,9 +32,7 @@ class DashXAppDelegate: NSObject {
|
|
|
27
32
|
return
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
DashXEventEmitter.instance.dispatch(name: "messageReceived", body: properties)
|
|
35
|
+
completionHandler(.newData)
|
|
36
|
+
DashXEventEmitter.instance.dispatch(name: "messageReceived", body: userInfo)
|
|
34
37
|
}
|
|
35
38
|
}
|