Permissions - StansAssets/com.stansassets.ultimate-mobile GitHub Wiki
Unlike the Android, where permissions can be queried from a single access point using the Runtime Permissions SDK. On iOS, permissions are bound to each module, and modules can have different permissions API, and provide a different scope of information. You can get more information about with iOS Native Permissions guide.
To simplify cross-platform permissions management, and also provide an ability to test the flow inside an Editor, Ultimate Mobile plugin contains the Unified Permissions API.
Use UM_Permissions as the main entry point for the Permissions Services APIs. The UM_Permissions contains UM_IPermission clients for:
- Contacts
- Notifications
- Camera
- Photos
The UM_IPermission client interface is pretty simple to use, see the declaration below:
namespace SA.CrossPlatform.App
{
public interface UM_IPermission
{
/// <summary>
/// Requests the user’s permission, if needed.
///
/// After the user grants permission, the system remembers the choice for future use in your app,
/// but the user can change this choice at any time using the Settings app.
/// If user denied your app access, this choice will also be remembered and attempt to call
/// RequestAccess again will not display any permission prompt and failed result will be fired immediately.
/// </summary>
/// <param name="callback">Callback fired upon determining your app’s authorization to access requested permission.</param>
void RequestAccess(Action<AuthorizationStatus> callback);
}
}
And of course, there is an example of how you can request Camera permission**.** The code would look the same for any other permission client.
Note: Plese make sure you enable iOS module correspondent to permissions API you going to use. See the description inside the UM_Permissions or check modules & permissions dependency with the iOS Native Permissions guide.
using SA.CrossPlatform.App;
...
UM_Permissions.Camera.RequestAccess((status) =>
{
if (status == AuthorizationStatus.Granted)
{
Debug.Log("Camera Access Granted");
}
else
{
Debug.Log("Camera Access Denied");
}
});