Permissions: revoke() method

Note: This feature is available in Web Workers.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

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 navigator.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

js
revoke(permissionDescriptor)

Parameters

permissionDescriptor

An object that sets options for the revoke operation. The available options for this descriptor depend on the permission type.

All permissions have a name:

name

A string containing the name of the API whose permissions you want to query. The returned Promise will reject with a TypeError if the permission name is not supported by the browser.

For the push permissions you can also specify:

userVisibleOnly Optional

(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.

For the midi permission you can also specify:

sysex Optional

Indicates whether you need and/or receive system exclusive messages. The default is false.

Return value

A Promise that calls its fulfillment handler with a PermissionStatus object indicating the result of the request.

Exceptions

TypeError

Retrieving the PermissionDescriptor information failed in some way, or the permission doesn't exist or is currently unsupported (e.g., midi, or push with userVisibleOnly).

Examples

This function can be used by an app to request that its own Geolocation API permission be revoked.

js
function revokePermission() {
  navigator.permissions.revoke({ name: "geolocation" }).then((result) => {
    report(result.state);
  });
}

Specifications

Specification
Relinquishing Permissions
# dom-permissions-revoke

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
revoke
Deprecated
Chrome – No support
Chrome 46 (Release date: 2015-10-13)
disabled
disabled From version 46 users must explicitly set the #enable-experimental-web-platform-features preference to Enabled. To change preferences in Chrome, visit chrome://flags.
Edge – No support
Edge 79 (Release date: 2020-01-15)
disabled
disabled From version 79 users must explicitly set the #enable-experimental-web-platform-features preference to Enabled. To change preferences in Edge, visit about:flags.
Firefox – No support
Firefox 47 – 50 (Release date: 2016-06-07)
unknown Support unknown
Firefox – No support
Firefox 51 (Release date: 2017-01-24)
disabled
disabled From version 51 users must explicitly set the dom.permissions.revoke.enable preference to true. To change preferences in Firefox, visit about:config.
Opera – No support
Opera 33 (Release date: 2015-10-27)
disabled
disabled From version 33 users must explicitly set the #enable-experimental-web-platform-features preference to Enabled. To change preferences in Opera, visit opera://flags.
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android 46 (Release date: 2015-10-14)
disabled
disabled From version 46 users must explicitly set the #enable-experimental-web-platform-features preference to Enabled. To change preferences in Chrome Android, visit chrome://flags.
Firefox for Android – No support
Firefox for Android 47 – 50 (Release date: 2016-06-07)
footnote Removed in 51 and later
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Deprecated. Not for use in new websites.
User must explicitly enable this feature.
Has more compatibility info.