File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,12 @@ export function setInterval(interval: number): void;
193193 * @platform ios
194194 */
195195export function setPausesLocationUpdatesAutomatically ( value : boolean = false ) : void ;
196+ /**
197+ * 是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。
198+ * 设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
199+ * @platform ios
200+ */
201+ export function setAllowsBackgroundLocationUpdates ( value : boolean = false ) : void ;
196202/**
197203 * 设定定位的最小更新距离。单位米,默认,表示只要检测到设备位置发生变化就会更新位置信息。
198204 * @platform ios
Original file line number Diff line number Diff line change @@ -157,6 +157,16 @@ export default class AMapGeolocation {
157157 return NativeModules . RNAMapGeolocation . setPausesLocationUpdatesAutomatically ( value ) ;
158158 }
159159 }
160+ /**
161+ * 是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。
162+ * 设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
163+ * @platform ios
164+ */
165+ static setAllowsBackgroundLocationUpdates ( value = false ) {
166+ if ( Platform . OS === "ios" ) {
167+ return NativeModules . RNAMapGeolocation . setAllowsBackgroundLocationUpdates ( value ) ;
168+ }
169+ }
160170 /**
161171 * 设置发起定位请求的时间间隔,单位:毫秒,默认值:2000毫秒
162172 * @platform android
Original file line number Diff line number Diff line change @@ -29,8 +29,6 @@ - (instancetype)init {
2929 [_manager setDesiredAccuracy: kCLLocationAccuracyHundredMeters ];
3030 // 设置不允许系统暂停定位
3131 [_manager setPausesLocationUpdatesAutomatically: NO ];
32- // 设置允许在后台定位
33- [_manager setAllowsBackgroundLocationUpdates: YES ];
3432
3533 [[AMapServices sharedServices ] setEnableHTTPS: YES ];
3634
@@ -127,6 +125,11 @@ - (instancetype)init {
127125RCT_EXPORT_METHOD (setPausesLocationUpdatesAutomatically: (BOOL )value) {
128126 _manager.pausesLocationUpdatesAutomatically = value;
129127}
128+ // 是否允许后台定位。默认为NO。只在iOS 9.0及之后起作用。
129+ // 设置为YES的时候必须保证 Background Modes 中的 Location updates 处于选中状态,否则会抛出异常。
130+ RCT_EXPORT_METHOD (setAllowsBackgroundLocationUpdates: (BOOL )value) {
131+ _manager.allowsBackgroundLocationUpdates = value;
132+ }
130133
131134/* *
132135 * @brief 转换目标经纬度为高德坐标系,不在枚举范围内的经纬度将直接返回。
You can’t perform that action at this time.
0 commit comments