Permissions

The Permissions API is designed to support new permissions checking mechanism. Permissions are requested at time of use rather than at runtime.

Usage
//Request one permission - STORAGE
Permissions.requestPermission(Permissions.STORAGE)
.then(function(result) {
    if(result.hasPermission)
        console.log("Permission granted");
    else
        console.log("Permission not granted");
    
})
.catch(function(e) {
    console.error('Unable to request permission:', e);
});

...

//Request two permissions - STORAGE and MICROPHONE
Permissions.requestPermissions([Permissions.STORAGE, Permissions.MICROPHONE])
.then(function(result) {
    if(result.hasPermission)
        console.log("Permission granted");
    else
        console.log("Permission not granted");
    
})
.catch(function(e) {
    console.error('Unable to request permission:', e);
});

... 

//Checking if have PHONE permission
Permissions.checkPermission(permissions.PHONE)
.then(function(result) {
    if(result.hasPermission)
        console.log("Permission granted");
    else
        console.log("Permission not granted");
    
})
.catch(function(e) {
    console.error('Unable to request permission:', e);
});
window.Permissions.requestPermission(window.Permissions.STORAGE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });

window.Permissions.checkPermission(window.permissions.PHONE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });
window.Permissions.requestPermission(window.Permissions.STORAGE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });
    
window.Permissions.checkPermission(window.permissions.PHONE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });
(window).Permissions.requestPermission((window).Permissions.STORAGE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });

(window).Permissions.checkPermission((window).permissions.PHONE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });
window.Permissions.requestPermission(window.Permissions.STORAGE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });
    
window.Permissions.checkPermission(window.permissions.PHONE)
    .then(function (result) {
        if (result.hasPermission) console.log("Permission granted");
        else console.log("Permission not granted");
    })
    .catch(function (e) {
        console.error("Unable to request permission:", e);
    });

Classes

Permissions

checkPermission
checkPermission(permission: PermissionsName): Promise<CheckPermissionResult>

Check Permission.


PARAMETERS
permission: PermissionsName

RETURN
returns: Promise<CheckPermissionResult>
requestPermission
requestPermission(permission: PermissionsName): Promise<CheckPermissionResult>

Request permission.


PARAMETERS
permission: PermissionsName

RETURN
returns: Promise<CheckPermissionResult>
requestPermissions
requestPermissions(permission: PermissionsName[]): Promise<CheckPermissionResult>

Request permissions.


PARAMETERS
permission: PermissionsName[]

RETURN
returns: Promise<CheckPermissionResult>

Interfaces Used

CheckPermissionResult

CheckPermissionResult {    
    hasPermission: boolean; 
}

Enumeration

PermissionsName

enum PermissionsName{
    STORAGE : 'STORAGE',// Allows an application to read/write on external storage. 
    CAMERA : 'CAMERA',// Required to be able to access the camera device. 
    LOCATION : 'LOCATION',// Allows an app to access location. 
    MICROPHONE : 'MICROPHONE',//  Allows an application to record audio.
    PHONE : 'PHONE',//  Allows read only access to phone state, including the current cellular network information.
    CALENDAR : 'CALENDAR',// Allows an application to read/write the user's calendar data.
    CONTACTS : 'CONTACTS'//  Allows an application to read/write the user's contacts data.
}