You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@ng-web-apis/permissions

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ng-web-apis/permissions

A library for comfortable use of Permissions API in Angular applications

4.12.0
latest
Source
npmnpm
Version published
Weekly downloads
2.1K
-39.75%
Maintainers
4
Weekly downloads
 
Created
Source

ng-web-apis logo Permissions API for Angular

npm version npm bundle size codecov

This is a library to use Permissions API with Angular.

Install

If you do not have @ng-web-apis/common:

npm i @ng-web-apis/common

Now install the package:

npm i @ng-web-apis/permissions

How to use

PermissionsService

Import service in your component:

import { PermissionsService } from '@ng-web-apis/permissions';

...
constructor(private readonly permissions: PermissionsService) {}

Now, use the service to retrieve the state of the permission in question. Below is an example of checking the permission to use geolocation:

const geolocationStatus$ = this.permissions.state('geolocation');
geolocationStatus$.subscribe((geolocationStatus) => doSomething(geolocationStatus));

Note, that a call to the permissions.state() returns an observable, which will emit new values in case the state for the permission in question changes. If you need to get state just once and stop observing the permission, you can use take(1) RxJs operator:

geolocationStatus$.pipe(take(1)).subscribe((geolocationStatus) => doSomething(geolocationStatus));

The observable is cold, meaning if there are no active subscriptions, it doesn't track the status of the permission.

Tokens

The library also provides a tokens to simplify working with Permissions API:

  • PERMISSIONS_SUPPORT returns true if user's browser supports Permissions API
export class Example {
  constructor(@Inject(PERMISSIONS_SUPPORT) private readonly permissionsSupport: boolean) {}
}

Browser support

IE / EdgeFirefoxChromeSafari
79+46+43+16+

See also

Other Web APIs for Angular by @ng-web-apis

Keywords

angular

FAQs

Package last updated on 31 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts