Skip to content

Commit f1ecbbe

Browse files
zwu52Feiyang1
authored andcommitted
Fix Context Check in Messaging-Compat (#5353)
1 parent 53e2128 commit f1ecbbe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/messaging-compat/src/registerMessagingCompat.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ declare module '@firebase/component' {
3434
const messagingCompatFactory: InstanceFactory<'messaging-compat'> = (
3535
container: ComponentContainer
3636
) => {
37-
if (!!navigator) {
38-
// in window
37+
if (self && 'ServiceWorkerGlobalScope' in self) {
38+
// in sw
3939
return new MessagingCompatImpl(
4040
container.getProvider('app-compat').getImmediate(),
41-
container.getProvider('messaging').getImmediate()
41+
container.getProvider('messaging-sw-exp').getImmediate()
4242
);
4343
} else {
44-
// in sw
44+
// in window
4545
return new MessagingCompatImpl(
4646
container.getProvider('app-compat').getImmediate(),
47-
container.getProvider('messaging-sw').getImmediate()
47+
container.getProvider('messaging').getImmediate()
4848
);
4949
}
5050
};

0 commit comments

Comments
 (0)