Version: 2023.1
Deep linking on iOS
准备应用程序进行应用内购 (IAP)

iOS authorizations in Unity

Apple’s operating system requires applications to request authorization before accessing sensitive information or device features. If your application requires access to features such as the device’s camera, microphone, or location, the device user must grant access to your application.

For more information on requesting authorizations on iOS devices, refer to the Apple documentation.

To access the device features that your application requires, you must:

  1. Provide a feature usage description in the info.plist file.
  2. Send a request for authorization.

Provide feature usage description

A feature usage description or purpose string is a message that the iOS system displays when your application tries to access the device feature. It’s best practice to add a clear description stating the reason for application access.

You can enter the feature usage description in Configuration section of Player settings (menu: Edit > Project Settings > Player > Other Settings). When you add the usage description to Player settings, Unity also adds it as a key-value pair to the info.plist file. For example, if your application wants to access the device camera, add Camera usage description in the Player settings. The description you enter automatically appears as NSCameraUsageDescription key value in the info.plist file. For more information, refer to Apple-specific iOS Player Settings.

Alternatively, you can directly add the required feature usage description key-value pairs in the info.plist file.

Send a request for authorization

After you add the feature usage description, send a request for camera or microphone access using Application.RequestUserAuthorization method. The system displays a dialog describing the request for authorization.

For a code example that shows how to use this API, refer to Application.RequestUserAuthorization.

For information about accessing device location, refer to LocationService API.

You can check the authorization status of your request using Application.HasUserAuthorization method.

Note: The device user can modify the feature authorization through device settings at any given time. You can use Application.HasUserAuthorization method to verify the authorization status of a feature before accessing it.

Deep linking on iOS
准备应用程序进行应用内购 (IAP)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961