puter.notifications.hasPermission()

Websites Puter Apps Node.js Workers

Whether the user lets your app send push notifications. It never prompts, so use it to decide whether to show your own "turn on notifications" button, which calls requestPermission().

The answer is about the app making the call. Called from an account session with no app, such as Node.js with an account token, it's always true.

Syntax

puter.notifications.hasPermission()

Parameters

None.

Return value

A Promise that resolves to true or false.

Examples

Only offer the button when it's needed

if ( ! await puter.notifications.hasPermission() ) {
    showEnablePushesButton();
}