enableBackgroundLocation method
仅支持android
开启后台定位功能 注意: 如果您设置了target>=28,需要增加android.permission.FOREGROUND_SERVICE
权限,
如果您的app需要运行在Android Q版本的手机上,需要为ApsService增加android:foregroundServiceType="location"属性,
例:
Implementation
Future<bool> enableBackgroundLocation(
AMapNotificationForAndroid notification) async {
if (!_isAndroid || !_isInitialize) return false;
final bool? state = await _channel.invokeMethod<bool>(
'enableBackgroundLocation', notification.toMap());
return state ?? false;
}