os_check_permission

使用此函数,您可以检查用户是否已授予游戏特定权限。
您使用格式"android.permission.<permission>",因此要检查RECORD_AUDIO权限(例如),您将调用

os_check_permission("android.permission.RECORD_AUDIO");

函数将返回将返回三个常量之一
——如下所示——
来告诉游戏如何获得许可的状态。
有关应用权限的更多信息,请参阅Android文档

重要!此函数仅适用于Android目标。

 

语法:

os_check_permission(permission)

参数类型描述
permissionString检查(字符串)的权限

 

返回:

许可状态常数

许可状态常数
常量描述
os_permission_grantedThis indicates that the permission has been granted
os_permission_deniedThis indicates that the permission has not been granted
os_permission_denied_dont_requestThis indicates that the permission has either been blocked by the phone settings, or that the user has previously denied the request and selected "Don't ask again".

 

例子:

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

上面的代码检查操作系统类型,如果是Android,它会对权限进行检查,如果尚未授予"InterNET"权限,它会请求它。