puter.notifications.hasPermission()

Websites Puter Apps Node.js Workers

Checks whether the user lets your app send push notifications.

It never prompts, so use it to decide whether to ask with requestPermission().

The user gives this permission in Puter's prompt, or on a website by turning pushes on with enable(). It says nothing about the browser the user is in. To check whether pushes reach this browser, use status().

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

Ask only when the app isn't allowed yet

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