AccountPush

AccountPush: the browsers that show the signed-in person NoClick's notifications (Web Push).

class AccountPush

The browsers that show the signed-in person NoClick's notifications: a DM or

Attributes
configuredboolean

Whether this NoClick sends notifications to browsers.

publicKeystring | null

The key a browser subscribes with (applicationServerKey), base64url.

devicesreadonly PushDevice[]
rawJsonObject

The response JSON exactly as the API sent it.

Types
type JsonObject = { [key: string]: unknown };

getstatic

static get(options?: { client?: NoClick }): Promise<AccountPush>

Read the browsers that show the person's notifications, and the key a new one subscribes with.

const { publicKey, devices } = await AccountPush.get();
Parameters
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The browsers (devices), whether this NoClick sends notifications to browsers (configured) and the key a new one subscribes with (public_key).

addstatic

static add(
  subscription: PushSubscriptionJson,
  options?: { device?: string; client?: NoClick },
): Promise<PushDevice>

Turn notifications on in this browser, with its push subscription: the same browser again (or one signed in to another account before) is updated, never added twice. device names it for the person, like iPhone.

const subscription = await registration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: publicKey });
const { id } = await AccountPush.add(subscription.toJSON(), { device: "iPhone" });
Parameters
subscriptionPushSubscriptionJsonrequired
options.devicestring
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The browser, as it's kept.

Types
/** A browser's push subscription, as `PushSubscription.toJSON()` gives it. */
interface PushSubscriptionJson {
  endpoint?: string;
  keys?: Record<string, string>;
}

removestatic

static remove(deviceId: string, options?: { client?: NoClick }): Promise<void>

Turn notifications off in one browser.

await AccountPush.remove(id);
Parameters
deviceIdstringrequired
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

Nothing.

PushDevice

interface PushDevice

One browser that shows the person's notifications, as its push service names it (endpoint).

Attributes
idstring
devicestring | null
endpointstring
createdAtDate | null
lastSentAtDate | null