0.0.1 • Published 1 year ago

@symplify.com/webpush-react v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Symplify Web Push for React

Install

npm install @symplify.com/webpush-react

or

yarn add @symplify.com/webpush-react

API

Types:

interface Message {
  id: string;
  userId: string;
  hasBeenRead: boolean;
  subject: string;
  body?: string;
  loadBody: () => void;
  deleteMessage: () => void;
  markRead: () => void;
}

Hooks:

useWebPush(userHash: string | null): void

Initiate Symplify Web Push. Use hook in a component rendered on all pages.

useMessages(): Message[]

Get a list of all web push messages. Will rerender when new messages becomes available.

useNewMessage(): Message

Listen for new incoming messages. For instance when focus is returned to the browser window and new messages has been sent while away, this hook will rerender with the new message. This messages will always contain the message body.