Skip to main content

Permissions

notification-kit has two permission paths. They exist for different callers and you usually use just one.

When the kit is initialized with a provider, request permission through the kit. This runs provider-specific work (FCM registration, the OneSignal prompt):

import { notifications } from 'notification-kit';

const granted = await notifications.requestPermission(); // boolean
const status = await notifications.checkPermission(); // PermissionStatus
const isOn = await notifications.isPermissionGranted(); // boolean

requestPermission() also emits a permissionChanged event you can observe globally:

notifications.on('permissionChanged', (e) => {
// e.granted, e.status
});

Standalone permission helper

For callers that are not going through a provider, the library exports a provider-agnostic permissions manager:

import { permissions } from 'notification-kit';

const status = await permissions.check();
const result = await permissions.request();

This is a generic permission API; prefer the kit's requestPermission() when a provider is configured so the provider's registration runs too.

Permission states

PermissionStatus is one of:

StatusMeaning
grantedThe user allowed notifications.
deniedThe user blocked notifications.
promptNot yet asked — safe to request.
provisionaliOS quiet (provisional) authorization.
defaultBrowser default (not yet decided).
unknownCould not determine.

Opening system settings

permissions.openSettings() is intentionally not implemented internally. Opening the OS settings screen requires a native plugin, and adding one would break the zero-dependency philosophy. The method throws a descriptive error telling you to wire your own settings plugin (for example @capacitor/app + a deep link, or a community settings plugin) if you need to send a blocked user to settings.

Good practice

  • Ask in context, after the user does something that benefits from notifications — not on first launch.
  • Check checkPermission() first; only call requestPermission() when the status is prompt/default.
  • Provide a non-notification fallback when permission is denied.