web api instance method
Permissions: revoke() method
Available in workers
The revoke() method of the Permissions interface reverts a currently set permission back to its default state, which is usually prompt.
This method is called on the global Permissions object permissions.
This method is removed from the main permissions API specification because its use case is unclear.
Permissions are managed by the browser and the current permission model does not involve the site developer being able to imperatively request or revoke permissions. Browsers have shipped this API behind preferences but it’s unlikely to reach the standards track.
For more context, see the original discussion to remove permissions.revoke().
Syntax
revoke(permissionDescriptor)
Parameters
permissionDescriptor-
: An object that sets options for the
revokeoperation. The available options for this descriptor depend on the permission type.All permissions have a name:
name
For the
pushpermissions you can also specify:userVisibleOnlyOptional- : (Push only, not supported in Firefox — see the Browser Support section below) Indicates whether you want to show a notification for every message or be able to send silent push notifications.
The default is
false.
- : (Push only, not supported in Firefox — see the Browser Support section below) Indicates whether you want to show a notification for every message or be able to send silent push notifications.
The default is
For the
midipermission you can also specify:sysexOptional- : Indicates whether you need and/or receive system exclusive messages.
The default is
false.
- : Indicates whether you need and/or receive system exclusive messages.
The default is
-
Return value
A Promise that calls its fulfillment handler with a PermissionStatus object indicating the result of the request.
Exceptions
TypeError- : Retrieving the
PermissionDescriptorinformation failed in some way, or the permission doesn’t exist or is currently unsupported (e.g.,midi, orpushwithuserVisibleOnly).
- : Retrieving the
Examples
This function can be used by an app to request that its own Geolocation API permission be revoked.
function revokePermission() {
navigator.permissions.revoke({ name: "geolocation" }).then((result) => {
report(result.state);
});
}