Skip to content

Commit

Permalink
fix(messaging): messaging/unsupported-browser error loading the plu…
Browse files Browse the repository at this point in the history
…gin (#106)
  • Loading branch information
robingenz authored Jun 11, 2022
1 parent dd66abb commit c1a30cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-balloons-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@capacitor-firebase/messaging": patch
---

fix: `messaging/unsupported-browser` error
10 changes: 8 additions & 2 deletions packages/messaging/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
deleteToken,
getMessaging,
getToken,
isSupported,
onMessage,
} from 'firebase/messaging';

Expand All @@ -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<PermissionStatus> {
Expand Down

0 comments on commit c1a30cb

Please sign in to comment.