简体   繁体   English

Flutter 后台位置访问

[英]Flutter background location access

When I went to update my app on Google Play, I saw a warning about something called "Sensitive app permissions" that I haven't seen before.当我在 Google Play 上更新我的应用程序时,我看到了一条关于我以前从未见过的名为“敏感应用程序权限”的警告。 It seems to concern call, SMS, location and file access permissions.它似乎与通话、短信、位置和文件访问权限有关。

Google Play Policy center / Permissions Google Play 政策中心/权限

The Permissions declaration form on Google Play says Google Play 上的权限声明表

Location permissions位置权限

Not started Your app isn't compliant未启动 您的应用不合规

My app uses the Flutter Location plugin and Flutter Map plugin .我的应用程序使用Flutter Location 插件Flutter Map 插件 I request the INTERNET and ACCESS_FINE_LOCATION permissions in my manifest:我在清单中请求INTERNETACCESS_FINE_LOCATION权限:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Further reading on Requesting access to location in the background gives more info about coming changes to Google Play policy:进一步阅读在后台请求访问位置提供了有关 Google Play 政策即将更改的更多信息:

Timeline for review and approval changes审查和批准变更的时间表

Beginning September 30, 2020, we will start reviewing apps that request access to location in the background.从 2020 年 9 月 30 日开始,我们将开始审查请求在后台访问位置信息的应用。 If your app is impacted, you will be notified on the App content page (Policy > App content) in the Play Console to complete the permissions declaration form.如果您的应用受到影响,您会在 Play 管理中心的应用内容页面(政策 > 应用内容)上收到通知,以完成权限声明表。

Beginning January 18, 2021, all new apps (first published after April 16, 2020) submitted to Google Play that access location in the background will need to be approved before they can go live.从 2021 年 1 月 18 日开始,所有提交到 Google Play 的新应用(2020 年 4 月 16 日之后首次发布)都需要在后台访问位置获得批准才能上线。

Beginning March 29, 2021, all existing apps (first published before April 16, 2020) that access location in the background will need to be approved or they will be removed from Google Play.从 2021 年 3 月 29 日开始,所有在后台访问位置的现有应用(2020 年 4 月 16 日之前首次发布)都需要获得批准,否则将从 Google Play 下架。

So, should I worry about background location usage, even though I'm not requesting any permission for background location, or actively doing anything in my app to access it?那么,我是否应该担心后台位置的使用,即使我没有请求后台位置的任何许可,或者在我的应用程序中主动做任何事情来访问它?

I'm seeing the location icon (a map needle) in the status bar on my old phone running Android 7, even when the app was in the background.我在运行 Android 7 的旧手机的状态栏中看到位置图标(地图指针),即使该应用程序在后台运行也是如此。 I've also seen the occasional "high battery usage in the background" on Android 7. On Android 9 and 10 I have not seen this though.我还偶尔在 Android 7 上看到“后台电池使用率高”。在 Android 9 和 10 上,我还没有看到这一点。

I might have been sloppy to stop the location plugin when the app is "backgrounded" - however, I'm not requesting any permission for background location, so could the location plugin really collect location data in the background - and thereby violating the Google Play policy - without it?当应用程序处于“后台”时,我可能会草率地停止位置插件 - 但是,我没有请求任何后台位置权限,所以位置插件真的可以在后台收集位置数据 - 从而违反了 Google Play政策 - 没有它?

I added this to the app manifest我将此添加到应用程序清单中

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
    package="com.example.localstore">
 <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove"/>

source来源

我认为重要的是您需要将compileSdkVersiontargetSdkVersion增加到29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM