We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6104c68 commit b541b3cCopy full SHA for b541b3c
packages/functions/src/context.ts
@@ -85,16 +85,16 @@ export class ContextProvider {
85
}
86
87
async getInstanceIdToken(): Promise<string | undefined> {
88
- try {
89
- if (!this.messaging) {
90
- return undefined;
91
- }
+ if (
+ !this.messaging ||
+ !('Notification' in self) ||
+ Notification.permission !== 'granted'
92
+ ) {
93
+ return undefined;
94
+ }
95
- const token = await this.messaging.getToken();
- if (!token) {
96
97
- return token;
+ try {
+ return this.messaging.getToken();
98
} catch (e) {
99
// We don't warn on this, because it usually means messaging isn't set up.
100
// console.warn('Failed to retrieve instance id token.', e);
0 commit comments