Version: 1.3
语言 : 中文
Device features and permissions
Declare permissions for an application

OpenHarmony permissions in Tuanjie

To get permission to access device features or data outside of your Tuanjie application’s sandbox, there are two stages:

  1. At build time, declare the permission in the application’s OpenHarmony App module.
  2. At runtime, request permission from the user.

For some permissions, Tuanjie automatically handles both the build-time OpenHarmony App module entries and runtime permission requests. For more information, see Tuanjie-handled permissions.

Declare permissions

An OpenHarmony application can only request the user for permission to use device features or data that it declares in its OpenHarmony App module. This is the build-time stage of OpenHarmony permission handling. For information on how to declare permissions, see Declare permissions for an application.

Runtime permissions

You can request runtime permissions at any time while the application is running. It’s best practice to request permission for restricted data or a device feature when the application requires the data/feature for the first time. You should also show the user a message that explains why the application requires the data/feature before you send the request. This is important to give users context so they are less likely to deny the permission out of confusion.

For information on how to request permission at runtime, see Request runtime permissions.

Important: If you try to request the user for a permission that the OpenHarmony App module doesn’t declare, the device doesn’t show the permission dialogue.

Tuanjie-handled permissions

Depending on the Player Settings and Tuanjie APIs that the application uses, Tuanjie automatically adds some required permissions to the OpenHarmony App module and sends permission requests at runtime. This also applies to any plug-ins that the application uses.

The following list explains which permissions Tuanjie handles automatically:

  • If the application uses the Application.internetReachability property, Tuanjie adds the INTERNET permission to the OpenHarmony App module.
  • If the application uses a location API such as LocationService, Tuanjie adds the LOCATION permission to the OpenHarmony App module and requests permission from the user the first time that the application uses location.
  • If the application uses the WebCamTexture class Tuanjie adds the CAMERA permission to the OpenHarmony App module and requests permission from the user the first time that the application uses WebCamTexture.
  • If the application uses the Microphone class adds the RECORD_AUDIO permission to the OpenHarmony App module and requests permission from the user the first time that the application uses Microphone.

Other resource

Device features and permissions
Declare permissions for an application