expo-gaode-map 2.2.5-next.0 → 2.2.6-next.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.
@@ -18,16 +18,27 @@ public class ExpoGaodeMapModule: Module {
18
18
  private var permissionManager: PermissionManager?
19
19
  /// 隐私协议是否已同意(模块级别跟踪)
20
20
  private static var privacyAgreed: Bool = false
21
+ /// 隐私同意持久化 Key
22
+ private static let privacyDefaultsKey = "expo_gaode_map_privacy_agreed"
21
23
 
22
24
  public func definition() -> ModuleDefinition {
23
25
  Name("ExpoGaodeMap")
24
26
 
25
- // 模块初始化时不设置隐私合规
26
- // 需要在用户同意隐私协议后手动调用 updatePrivacyCompliance 方法
27
+ // 模块初始化:尝试从本地缓存恢复隐私同意状态
27
28
  OnCreate {
28
- // 仅更新隐私信息显示状态,不表示用户已同意
29
+ // 先确保隐私信息展示状态
29
30
  MAMapView.updatePrivacyShow(AMapPrivacyShowStatus.didShow, privacyInfo: AMapPrivacyInfoStatus.didContain)
30
- print("ℹ️ ExpoGaodeMap: 隐私信息已更新,但需要用户同意隐私协议才能使用 SDK")
31
+
32
+ // 从 UserDefaults 恢复上次的同意状态(默认 false)
33
+ let saved = UserDefaults.standard.bool(forKey: ExpoGaodeMapModule.privacyDefaultsKey)
34
+ ExpoGaodeMapModule.privacyAgreed = saved
35
+ if saved {
36
+ // 同步到 SDK
37
+ MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
38
+ print("🔁 ExpoGaodeMap: 已从缓存恢复隐私同意状态: true")
39
+ } else {
40
+ print("ℹ️ ExpoGaodeMap: 未发现已同意记录,等待用户同意后再使用 SDK")
41
+ }
31
42
  }
32
43
 
33
44
  // ==================== 隐私合规管理 ====================
@@ -37,10 +48,15 @@ public class ExpoGaodeMapModule: Module {
37
48
  * 必须在用户同意隐私协议后调用
38
49
  */
39
50
  Function("updatePrivacyCompliance") { (hasAgreed: Bool) in
51
+ // 更新内存状态
40
52
  ExpoGaodeMapModule.privacyAgreed = hasAgreed
53
+ // 持久化到本地,供下次启动自动恢复
54
+ UserDefaults.standard.set(hasAgreed, forKey: ExpoGaodeMapModule.privacyDefaultsKey)
55
+
41
56
  if hasAgreed {
57
+ // 同步到 SDK
42
58
  MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.didAgree)
43
- print("✅ ExpoGaodeMap: 用户已同意隐私协议,可以使用 SDK")
59
+ print("✅ ExpoGaodeMap: 用户已同意隐私协议,可以使用 SDK(状态已持久化)")
44
60
 
45
61
  // 在用户同意后,如果尚未设置 API Key,则尝试从 Info.plist 读取并设置
46
62
  if AMapServices.shared().apiKey == nil || AMapServices.shared().apiKey?.isEmpty == true {
@@ -54,7 +70,7 @@ public class ExpoGaodeMapModule: Module {
54
70
  }
55
71
  } else {
56
72
  MAMapView.updatePrivacyAgree(AMapPrivacyAgreeStatus.notAgree)
57
- print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,SDK 功能将受限")
73
+ print("⚠️ ExpoGaodeMap: 用户未同意隐私协议,SDK 功能将受限(状态已持久化)")
58
74
  }
59
75
  }
60
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-gaode-map",
3
- "version": "2.2.5-next.0",
3
+ "version": "2.2.6-next.0",
4
4
  "description": "一个功能完整的高德地图 React Native 组件库,基于 Expo Modules 开发,提供地图显示、定位、覆盖物等功能。",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",