File tree 4 files changed +22
-22
lines changed
packages-exp/messaging-exp/src
4 files changed +22
-22
lines changed Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- export function isSupported ( ) : boolean {
19
- if ( self && 'ServiceWorkerGlobalScope' in self ) {
20
- // Running in ServiceWorker context
21
- return isSWControllerSupported ( ) ;
22
- } else {
23
- // Assume we are in the window context.
24
- return isWindowControllerSupported ( ) ;
25
- }
26
- }
27
-
28
18
/**
29
19
* Checks to see if the required APIs exist.
30
20
*/
31
- function isWindowControllerSupported ( ) : boolean {
21
+ export function isWindowSupported ( ) : boolean {
32
22
return (
33
23
'indexedDB' in window &&
34
24
indexedDB !== null &&
@@ -45,7 +35,7 @@ function isWindowControllerSupported(): boolean {
45
35
/**
46
36
* Checks to see if the required APIs exist within SW Context.
47
37
*/
48
- function isSWControllerSupported ( ) : boolean {
38
+ export function isSwSupported ( ) : boolean {
49
39
return (
50
40
'indexedDB' in self &&
51
41
indexedDB !== null &&
Original file line number Diff line number Diff line change @@ -21,19 +21,13 @@ import {
21
21
ComponentType ,
22
22
InstanceFactory
23
23
} from '@firebase/component' ;
24
- import { ERROR_FACTORY , ErrorCode } from '../util/errors' ;
25
24
26
25
import { MessagingService } from '../messaging-service' ;
27
26
import { _registerComponent } from '@firebase/app-exp' ;
28
- import { isSupported } from './isSupported' ;
29
27
30
28
const messagingFactory : InstanceFactory < 'messaging-exp' > = (
31
29
container : ComponentContainer
32
30
) => {
33
- if ( ! isSupported ( ) ) {
34
- throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
35
- }
36
-
37
31
return new MessagingService (
38
32
container . getProvider ( 'app-exp' ) . getImmediate ( ) ,
39
33
container . getProvider ( 'installations-exp-internal' ) . getImmediate ( ) ,
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { FirebaseMessaging } from '@firebase/messaging-types-exp' ;
19
- import { registerMessaging } from './helpers/register' ;
20
18
import '@firebase/installations-exp' ;
21
19
20
+ import { ERROR_FACTORY , ErrorCode } from './util/errors' ;
21
+
22
+ import { FirebaseMessaging } from '@firebase/messaging-types-exp' ;
23
+ import { isSwSupported } from './helpers/isSupported' ;
24
+ import { registerMessaging } from './helpers/registerMessaging' ;
25
+
22
26
export { onBackgroundMessage , getMessaging } from './api' ;
23
27
24
28
declare module '@firebase/component' {
@@ -27,4 +31,8 @@ declare module '@firebase/component' {
27
31
}
28
32
}
29
33
34
+ if ( ! isSwSupported ( ) ) {
35
+ throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
36
+ }
37
+
30
38
registerMessaging ( ) ;
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { FirebaseMessaging } from '@firebase/messaging-types-exp' ;
19
- import { registerMessaging } from './helpers/register' ;
20
18
import '@firebase/installations-exp' ;
21
19
20
+ import { ERROR_FACTORY , ErrorCode } from './util/errors' ;
21
+
22
+ import { FirebaseMessaging } from '@firebase/messaging-types-exp' ;
23
+ import { isWindowSupported } from './helpers/isSupported' ;
24
+ import { registerMessaging } from './helpers/registerMessaging' ;
25
+
22
26
export {
23
27
getToken ,
24
28
deleteToken ,
@@ -34,4 +38,8 @@ declare module '@firebase/component' {
34
38
}
35
39
}
36
40
41
+ if ( ! isWindowSupported ( ) ) {
42
+ throw ERROR_FACTORY . create ( ErrorCode . UNSUPPORTED_BROWSER ) ;
43
+ }
44
+
37
45
registerMessaging ( ) ;
You can’t perform that action at this time.
0 commit comments