diff --git a/.changeset/breezy-balloons-kneel.md b/.changeset/breezy-balloons-kneel.md new file mode 100644 index 00000000..d8a8ff2c --- /dev/null +++ b/.changeset/breezy-balloons-kneel.md @@ -0,0 +1,5 @@ +--- +"@capacitor-firebase/messaging": patch +--- + +fix: `messaging/unsupported-browser` error diff --git a/packages/messaging/src/web.ts b/packages/messaging/src/web.ts index 23783a62..a61ccb2f 100644 --- a/packages/messaging/src/web.ts +++ b/packages/messaging/src/web.ts @@ -5,6 +5,7 @@ import { deleteToken, getMessaging, getToken, + isSupported, onMessage, } from 'firebase/messaging'; @@ -30,8 +31,13 @@ export class FirebaseMessagingWeb constructor() { super(); - const messaging = getMessaging(); - onMessage(messaging, payload => this.handleNotificationReceived(payload)); + isSupported().then(supported => { + if (!supported) { + return; + } + const messaging = getMessaging(); + onMessage(messaging, payload => this.handleNotificationReceived(payload)); + }); } public async checkPermissions(): Promise {