harmony 鸿蒙Applying for Location Permissions (ArkTS)
Applying for Location Permissions (ArkTS)
Scenario
Before using the capabilities provided by Location Kit, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user.
The system provides the following location permission:
ohos.permission.LOCATION: used to obtain location accurate to meters.
ohos.permission.APPROXIMATELY_LOCATION: used to obtain location accurate to 5 kilometers.
ohos.permission.LOCATION_IN_BACKGROUND: used to obtain location while the application is running at the background.
For details about the permissions required for each API of Location Kit, see Location Kit.
How to Develop
Declare the required permission in your application’s configuration file. For details, see Requesting User Authorization.
If your application needs to access the device location when running in the foreground, declare the location permission as described in the following table.
Permission | Declarable or Not | Location Accuracy |
---|---|---|
ohos.permission.APPROXIMATELY_LOCATION | Yes | Location accurate to 5 kilometers. |
ohos.permission.APPROXIMATELY_LOCATION and ohos.permission.LOCATION | Yes | Location accurate to meters. |
- If your application needs to access the device location when running in the background, declare the location permission as follows:
If your application needs to access the device location when running in the background, also request for a continuous task of the LOCATION type in addition to the permission declared in step 2.
For details about how to request for a continuous task, see Continuous Task and Continuous Task Development Example.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙FenceExtensionAbility
harmony 鸿蒙Geocoding and Reverse Geocoding (ArkTS)
harmony 鸿蒙Obtaining Device Location Information (C/C++)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦