os_request_permission


Description

With this function you can request a specific permission. You supply the permission to request as a string using the format "android.permission.<permission>", so to request the RECORD_AUDIO permission (for example) you would call

os_request_permission("android.permission.RECORD_AUDIO");

The function will return trigger a System Asynchronous Event where the built in async_load DS map will contain the following key/value pairs:

It is worth noting that the following permission are supported natively by GameMaker Studio 2, but are considered "dangerous" by Google and as such they must be explicitly requested (note too that some permissions can be requested using the Android Game Options without the need for this function):

For more information on app permissions, please see the Android Documentation.

IMPORTANT! This function is for the Android and Amazon Fire targets only.


Syntax:

os_request_permission(permission)

Argument Description
permission The permission to request (a string)


Returns:

N/A


Example:

if os_type == os_android
    {
    if os_check_permission("android.permission.INTERNET") == os_permission_denied
        {
        os_request_permission("android.permission.INTERNET");
        }
    }

The above code checks the OS type and if is Android, it performs a check on the permissions and if the "INTERNET" permission has not yet been granted, it requests it.