The Permissions API is designed to support new permissions checking mechanism. Permissions are requested at time of use rather than at runtime.
//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);
});
checkPermission(permission: PermissionsName): Promise<CheckPermissionResult>
Check Permission.
requestPermission(permission: PermissionsName): Promise<CheckPermissionResult>
Request permission.
requestPermissions(permission: PermissionsName[]): Promise<CheckPermissionResult>
Request permissions.
CheckPermissionResult { hasPermission: boolean; }
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. }