Fcm
Wrapper for firebase cloud messaging .
⚡️ Prerequisites
npm install --save firebase
npm install --save firebase
sh
Usage
<script>
import { initializeApp } from "firebase/app"
import {fcm} from "@sveu/extend/fcm"
const config = {
...
}
const app = initializeApp(config)
const { token, error, supported, messaging, onMessage } = fcm(firebase, "vapid key")
</script>
<script>
import { initializeApp } from "firebase/app"
import {fcm} from "@sveu/extend/fcm"
const config = {
...
}
const app = initializeApp(config)
const { token, error, supported, messaging, onMessage } = fcm(firebase, "vapid key")
</script>
svelte
API
Arguments
Name | Description | Type | Required |
---|---|---|---|
firebase | Firebase app instance. | firebase.app.App | Yes |
vapidKey | VAPID key. | string | Yes |
Options
Nam | Description | Type | Default |
---|---|---|---|
swPath | The url path to the service worker file. | string | No default |
Returns
Name | Description | Type |
---|---|---|
token | The token to use for push notifications. | Readable<string > |
error | Readable store that contains error if one occurred. | Readable<Error > |
supported | Indicates whether FCM is supported. | Readable<boolean > |
messaging | The firebase messaging instance. | Readable<firebase.messaging.Messaging > |
onMessage | The function to handle incoming messages. | fn: (payload: unknown) => void |