@onekeyfe/react-native-device-utils 3.0.57 → 3.0.58

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.
@@ -1,6 +1,7 @@
1
1
  import NitroModules
2
2
  import UIKit
3
3
  import ReactNativeNativeLogger
4
+ import os
4
5
 
5
6
  @objcMembers
6
7
  public class LaunchOptionsStore: NSObject {
@@ -34,8 +35,20 @@ public class LaunchOptionsStore: NSObject {
34
35
 
35
36
  private static let deviceTokenKey = "1k_device_token"
36
37
 
37
- // Read-once: hand the payload to JS exactly once per launch.
38
+ // Serializes access to `coldStartLocalNotification`. The getter resolves on a
39
+ // nitro background thread (Promise.async) while AppDelegate writes the slot on
40
+ // the main thread during launch, so the read-and-clear below must be one
41
+ // critical section to avoid a double-drain race (delivering the deep-link
42
+ // twice) and memory-visibility issues. NOTE: AppDelegate writes via KVC
43
+ // (`setValue(_:forKey:)`), which bypasses this lock, so we cannot fully
44
+ // synchronize the writer from here — we protect the take side as best we can.
45
+ private var coldStartLock = os_unfair_lock()
46
+
47
+ // Read-once: hand the payload to JS exactly once per launch. The read+clear is
48
+ // performed atomically under `coldStartLock`.
38
49
  public func takeColdStartLocalNotification() -> String {
50
+ os_unfair_lock_lock(&coldStartLock)
51
+ defer { os_unfair_lock_unlock(&coldStartLock) }
39
52
  let value = coldStartLocalNotification ?? ""
40
53
  coldStartLocalNotification = nil
41
54
  return value
@@ -209,7 +222,10 @@ class ReactNativeDeviceUtils: HybridReactNativeDeviceUtilsSpec {
209
222
 
210
223
  func getAndClearColdStartLocalNotification() throws -> Promise<String> {
211
224
  return Promise.async {
212
- return LaunchOptionsStore.shared.takeColdStartLocalNotification()
225
+ let value = LaunchOptionsStore.shared.takeColdStartLocalNotification()
226
+ // Presence only — never log the payload (it's a deep-link target / PII).
227
+ OneKeyLog.info("DeviceUtils", "getAndClearColdStartLocalNotification: hasPayload=\(!value.isEmpty)")
228
+ return value
213
229
  }
214
230
  }
215
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-device-utils",
3
- "version": "3.0.57",
3
+ "version": "3.0.58",
4
4
  "description": "react-native-device-utils",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",