capacitor-baidu-location 0.0.3 → 0.0.4
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/README.md
CHANGED
|
@@ -67,9 +67,9 @@ export default config;
|
|
|
67
67
|
### Android 配置
|
|
68
68
|
|
|
69
69
|
1. **API Key 配置**
|
|
70
|
-
- 百度地图 API Key
|
|
71
|
-
- **方式一:动态设置**:在应用代码中调用 `setAK`
|
|
72
|
-
- **方式二:配置文件设置**:在 `capacitor.config.ts` 中配置
|
|
70
|
+
- 百度地图 API Key 可以通过2种方式配置(优先级从高到低):
|
|
71
|
+
- **方式一:动态设置**:在应用代码中调用 `setAK` 方法,通过参数设置;
|
|
72
|
+
- **方式二:配置文件设置**:在 `capacitor.config.ts` 中配置 `androidAK` ,之后一样要调用 `setAK` 方法,只是不需要传参.
|
|
73
73
|
|
|
74
74
|
**注意:AndroidManifest.xml 需要配置占位值**:
|
|
75
75
|
```xml
|
|
@@ -111,9 +111,9 @@ export default config;
|
|
|
111
111
|
### iOS 配置
|
|
112
112
|
|
|
113
113
|
1. **API Key 配置**
|
|
114
|
-
- 百度地图 API Key
|
|
114
|
+
- 百度地图 API Key 可以通过2种方式配置(优先级从高到低):
|
|
115
115
|
- **方式一:动态设置**:在应用代码中调用 `setAK` 方法设置
|
|
116
|
-
- **方式二:配置文件设置**:在 `capacitor.config.ts` 中配置
|
|
116
|
+
- **方式二:配置文件设置**:在 `capacitor.config.ts` 中配置 `iOSAK` ,之后一样要调用 `setAK` 方法,只是不需要传参.
|
|
117
117
|
|
|
118
118
|
2. **权限配置**
|
|
119
119
|
在 `Info.plist` 文件中添加以下权限描述:
|
|
@@ -354,8 +354,9 @@ const getCurrentCoordinateType = async () => {
|
|
|
354
354
|
|
|
355
355
|
## 版本更新
|
|
356
356
|
|
|
357
|
-
- **0.0.
|
|
358
|
-
-
|
|
357
|
+
- **0.0.4**:
|
|
358
|
+
- 修改文档
|
|
359
|
+
- ios 平台 allowsBackgroundLocationUpdates 配置动态读取
|
|
359
360
|
|
|
360
361
|
更多详情请参考 [CHANGELOG.md](CHANGELOG.md)
|
|
361
362
|
|
|
@@ -88,7 +88,7 @@ import Network
|
|
|
88
88
|
manager.desiredAccuracy = kCLLocationAccuracyBest // 默认定位精度
|
|
89
89
|
manager.activityType = .automotiveNavigation // 默认定位场景
|
|
90
90
|
manager.pausesLocationUpdatesAutomatically = false // 默认不被系统自动暂停定位
|
|
91
|
-
manager.allowsBackgroundLocationUpdates =
|
|
91
|
+
manager.allowsBackgroundLocationUpdates = isBackgroundLocationModeConfigured() // 允许后台定位,需要在xcode开启配置
|
|
92
92
|
manager.locationTimeout = 10 // 定位超时时间,单位:秒
|
|
93
93
|
manager.reGeocodeTimeout = 10 // 逆地理编码超时时间,单位:秒
|
|
94
94
|
return manager
|
|
@@ -113,7 +113,17 @@ import Network
|
|
|
113
113
|
clLocationManager.delegate = self
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
func isBackgroundLocationModeConfigured() -> Bool {
|
|
117
|
+
// 读取 Info.plist 中的 UIBackgroundModes 配置
|
|
118
|
+
guard let backgroundModes = Bundle.main.object(forInfoDictionaryKey: "UIBackgroundModes") as? [String] else {
|
|
119
|
+
print("未配置任何后台模式")
|
|
120
|
+
return false
|
|
121
|
+
}
|
|
122
|
+
// 检查是否包含 "location"(对应 Xcode 的 Location updates)
|
|
123
|
+
let hasLocationBackgroundMode = backgroundModes.contains("location")
|
|
124
|
+
print("Xcode 是否勾选后台定位模式:\(hasLocationBackgroundMode)")
|
|
125
|
+
return hasLocationBackgroundMode
|
|
126
|
+
}
|
|
117
127
|
|
|
118
128
|
// MARK: - AK管理
|
|
119
129
|
/**
|