MCPcopy Index your code
hub / github.com/NativeScript/firebase / Messaging

Class Messaging

packages/firebase-messaging/index.android.ts:21–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19});
20
21export class Messaging implements IMessaging {
22 _native: com.google.firebase.messaging.FirebaseMessaging;
23 _app: FirebaseApp;
24
25 _onMessage?: (message: RemoteMessage) => void;
26 _onNotificationTap?: (message: RemoteMessage) => void;
27 _onToken?: (token: string) => void;
28
29 showNotificationsWhenInForeground: boolean;
30 _instance: MessagingCore;
31 constructor() {
32 if (defaultMessaging) {
33 return defaultMessaging;
34 }
35 defaultMessaging = this;
36 this._instance = MessagingCore.getInstance();
37 }
38
39 getToken(): Promise<string> {
40 return new Promise((resolve, reject) => {
41 org.nativescript.firebase.messaging.FirebaseMessaging.getToken(
42 this.native,
43 new org.nativescript.firebase.messaging.FirebaseMessaging.Callback<string>({
44 onSuccess(result) {
45 resolve(result);
46 },
47 onError(error) {
48 reject(FirebaseError.fromNative(error));
49 },
50 })
51 );
52 });
53 }
54
55 getAPNSToken() {
56 return null;
57 }
58
59 hasPermission(): Promise<AuthorizationStatus> {
60 return this._instance.hasPermission() as any;
61 }
62
63 onMessage(listener: (message: RemoteMessage) => any) {
64 if (!listener && this._onMessage) {
65 this._instance.removeOnMessage(this._onMessage);
66 } else {
67 this._instance.addOnMessage(listener);
68 }
69
70 this._onMessage = listener;
71 }
72
73 onNotificationTap(listener: (message: RemoteMessage) => any) {
74 if (!listener && this._onNotificationTap) {
75 this._instance.removeOnNotificationTap(this._onNotificationTap);
76 } else {
77 this._instance.addOnNotificationTap(listener);
78 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…