@react-native-firebase/messaging 23.6.0 → 23.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/index.js +61 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/modular.js +439 -0
- package/dist/commonjs/modular.js.map +1 -0
- package/dist/commonjs/namespaced.js +407 -0
- package/dist/commonjs/namespaced.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/remoteMessageOptions.js +87 -0
- package/dist/commonjs/remoteMessageOptions.js.map +1 -0
- package/dist/commonjs/statics.js +29 -0
- package/dist/commonjs/statics.js.map +1 -0
- package/dist/commonjs/types/messaging.js +105 -0
- package/dist/commonjs/types/messaging.js.map +1 -0
- package/dist/commonjs/version.js +9 -0
- package/dist/commonjs/version.js.map +1 -0
- package/{ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.h → dist/module/index.js} +11 -12
- package/dist/module/index.js.map +1 -0
- package/{lib/modular/index.js → dist/module/modular.js} +135 -119
- package/dist/module/modular.js.map +1 -0
- package/{lib/index.js → dist/module/namespaced.js} +70 -193
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/{lib → dist/module}/remoteMessageOptions.js +10 -27
- package/dist/module/remoteMessageOptions.js.map +1 -0
- package/dist/module/statics.js +25 -0
- package/dist/module/statics.js.map +1 -0
- package/dist/module/types/messaging.js +124 -0
- package/dist/module/types/messaging.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/typescript/commonjs/lib/index.d.ts +6 -0
- package/dist/typescript/commonjs/lib/index.d.ts.map +1 -0
- package/{lib/modular/index.d.ts → dist/typescript/commonjs/lib/modular.d.ts} +86 -164
- package/dist/typescript/commonjs/lib/modular.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts +12 -0
- package/dist/typescript/commonjs/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts +14 -0
- package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/statics.d.ts +20 -0
- package/dist/typescript/commonjs/lib/statics.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/types/messaging.d.ts +673 -0
- package/dist/typescript/commonjs/lib/types/messaging.d.ts.map +1 -0
- package/dist/typescript/commonjs/lib/version.d.ts +2 -0
- package/dist/typescript/commonjs/lib/version.d.ts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/module/lib/index.d.ts +6 -0
- package/dist/typescript/module/lib/index.d.ts.map +1 -0
- package/dist/typescript/module/lib/modular.d.ts +247 -0
- package/dist/typescript/module/lib/modular.d.ts.map +1 -0
- package/dist/typescript/module/lib/namespaced.d.ts +12 -0
- package/dist/typescript/module/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/module/lib/remoteMessageOptions.d.ts +14 -0
- package/dist/typescript/module/lib/remoteMessageOptions.d.ts.map +1 -0
- package/dist/typescript/module/lib/statics.d.ts +20 -0
- package/dist/typescript/module/lib/statics.d.ts.map +1 -0
- package/dist/typescript/module/lib/types/messaging.d.ts +673 -0
- package/dist/typescript/module/lib/types/messaging.d.ts.map +1 -0
- package/dist/typescript/module/lib/version.d.ts +2 -0
- package/dist/typescript/module/lib/version.d.ts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/{ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.h → lib/index.ts} +28 -21
- package/lib/modular.ts +447 -0
- package/lib/namespaced.ts +583 -0
- package/lib/remoteMessageOptions.ts +110 -0
- package/lib/{statics.js → statics.ts} +6 -3
- package/lib/types/messaging.ts +815 -0
- package/lib/version.ts +2 -0
- package/package.json +64 -8
- package/tsconfig.json +21 -0
- package/CHANGELOG.md +0 -1177
- package/RNFBMessaging.podspec +0 -50
- package/android/.editorconfig +0 -10
- package/android/build.gradle +0 -149
- package/android/lint.xml +0 -5
- package/android/settings.gradle +0 -1
- package/android/src/main/AndroidManifest.xml +0 -43
- package/android/src/main/java/io/invertase/firebase/messaging/JsonConvert.java +0 -127
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingHeadlessService.java +0 -30
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingModule.java +0 -332
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingPackage.java +0 -41
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingReceiver.java +0 -66
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java +0 -225
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingService.java +0 -37
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStore.java +0 -15
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreHelper.java +0 -23
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreImpl.java +0 -97
- package/android/src/main/res/values/colors.xml +0 -143
- package/app.plugin.js +0 -1
- package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.h +0 -54
- package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m +0 -251
- package/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m +0 -70
- package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.h +0 -29
- package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.m +0 -173
- package/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +0 -185
- package/ios/RNFBMessaging/RNFBMessagingModule.h +0 -26
- package/ios/RNFBMessaging/RNFBMessagingModule.m +0 -431
- package/ios/RNFBMessaging/RNFBMessagingSerializer.h +0 -32
- package/ios/RNFBMessaging/RNFBMessagingSerializer.m +0 -235
- package/ios/RNFBMessaging.xcodeproj/project.pbxproj +0 -384
- package/ios/RNFBMessaging.xcodeproj/xcshareddata/IDETemplateMacros.plist +0 -24
- package/lib/index.d.ts +0 -1233
- package/lib/version.js +0 -2
- package/plugin/build/android/index.d.ts +0 -2
- package/plugin/build/android/index.js +0 -5
- package/plugin/build/android/setupFirebaseNotifationIcon.d.ts +0 -8
- package/plugin/build/android/setupFirebaseNotifationIcon.js +0 -62
- package/plugin/build/index.d.ts +0 -3
- package/plugin/build/index.js +0 -16
- package/plugin/tsconfig.tsbuildinfo +0 -1
package/lib/index.d.ts
DELETED
|
@@ -1,1233 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Firebase Messaging package for React Native.
|
|
22
|
-
*
|
|
23
|
-
* #### Example 1
|
|
24
|
-
*
|
|
25
|
-
* Access the firebase export from the `messaging` package:
|
|
26
|
-
*
|
|
27
|
-
* ```js
|
|
28
|
-
* import { firebase } from '@react-native-firebase/messaging';
|
|
29
|
-
*
|
|
30
|
-
* // firebase.messaging().X
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* #### Example 2
|
|
34
|
-
*
|
|
35
|
-
* Using the default export from the `messaging` package:
|
|
36
|
-
*
|
|
37
|
-
* ```js
|
|
38
|
-
* import messaging from '@react-native-firebase/messaging';
|
|
39
|
-
*
|
|
40
|
-
* // messaging().X
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* #### Example 3
|
|
44
|
-
*
|
|
45
|
-
* Using the default export from the `app` package:
|
|
46
|
-
*
|
|
47
|
-
* ```js
|
|
48
|
-
* import firebase from '@react-native-firebase/app';
|
|
49
|
-
* import '@react-native-firebase/messaging';
|
|
50
|
-
*
|
|
51
|
-
* // firebase.messaging().X
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @firebase messaging
|
|
55
|
-
*/
|
|
56
|
-
export namespace FirebaseMessagingTypes {
|
|
57
|
-
import FirebaseModule = ReactNativeFirebase.FirebaseModule;
|
|
58
|
-
import NativeFirebaseError = ReactNativeFirebase.NativeFirebaseError;
|
|
59
|
-
|
|
60
|
-
export interface Statics {
|
|
61
|
-
AuthorizationStatus: typeof AuthorizationStatus;
|
|
62
|
-
NotificationAndroidPriority: typeof NotificationAndroidPriority;
|
|
63
|
-
NotificationAndroidVisibility: typeof NotificationAndroidVisibility;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* The `RemoteMessage` interface describes an outgoing & incoming message from the remote FCM server.
|
|
68
|
-
*/
|
|
69
|
-
export interface RemoteMessage {
|
|
70
|
-
/**
|
|
71
|
-
* The collapse key a message was sent with. Used to override existing messages with the same
|
|
72
|
-
* key.
|
|
73
|
-
*/
|
|
74
|
-
collapseKey?: string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A unique ID assigned to every message.
|
|
78
|
-
*
|
|
79
|
-
* If not provided, a random unique ID is generated.
|
|
80
|
-
*/
|
|
81
|
-
messageId?: string;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The message type of the message.
|
|
85
|
-
*/
|
|
86
|
-
messageType?: string;
|
|
87
|
-
/**
|
|
88
|
-
* The topic name or message identifier.
|
|
89
|
-
*/
|
|
90
|
-
from?: string;
|
|
91
|
-
/**
|
|
92
|
-
* The address for the message.
|
|
93
|
-
*/
|
|
94
|
-
to?: string;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The time to live for the message in seconds.
|
|
98
|
-
*
|
|
99
|
-
* Defaults to 3600.
|
|
100
|
-
*/
|
|
101
|
-
ttl?: number;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The time the message was sent, in milliseconds since the start of unix epoch
|
|
105
|
-
*/
|
|
106
|
-
sentTime?: number;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Any additional data sent with the message.
|
|
110
|
-
*/
|
|
111
|
-
data?: { [key: string]: string | object };
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Additional NotificationPayload data sent with the message
|
|
115
|
-
*/
|
|
116
|
-
notification?: NotificationPayload;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Whether the iOS APNs message was configured as a background update notification.
|
|
120
|
-
*
|
|
121
|
-
* @platform ios iOS
|
|
122
|
-
*/
|
|
123
|
-
contentAvailable?: boolean;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Whether the iOS APNs `mutable-content` property on the message was set
|
|
127
|
-
* allowing the app to modify the notification via app extensions.
|
|
128
|
-
*
|
|
129
|
-
* @platform ios iOS
|
|
130
|
-
*/
|
|
131
|
-
mutableContent?: boolean;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* The iOS category this notification is assigned to.
|
|
135
|
-
*
|
|
136
|
-
* @platform ios iOS
|
|
137
|
-
*/
|
|
138
|
-
category?: string;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* An iOS app specific identifier used for notification grouping.
|
|
142
|
-
threadId?: string;
|
|
143
|
-
*/
|
|
144
|
-
threadId?: string;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Options for features provided by the FCM SDK for Web.
|
|
148
|
-
*/
|
|
149
|
-
fcmOptions: FcmOptions;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Priority - android-specific, undefined on non-android platforms, default PRIORITY_UNKNOWN
|
|
153
|
-
*/
|
|
154
|
-
priority?: MessagePriority;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Original priority - android-specific, undefined on non-android platforms, default PRIORITY_UNKNOWN
|
|
158
|
-
*/
|
|
159
|
-
originalPriority?: MessagePriority;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Represents the priority of a RemoteMessage
|
|
164
|
-
*
|
|
165
|
-
* Note: this is an android-specific property of RemoteMessages
|
|
166
|
-
*
|
|
167
|
-
* See https://github.com/firebase/firebase-android-sdk/blob/b6d01070d246b74f02c42da5691f99f52763e48b/firebase-messaging/src/main/java/com/google/firebase/messaging/RemoteMessage.java#L57-L64
|
|
168
|
-
*
|
|
169
|
-
* Example:
|
|
170
|
-
*
|
|
171
|
-
* ```js
|
|
172
|
-
* firebase.messaging.MessagePriority.PRIORITY_NORMAL;
|
|
173
|
-
* ```
|
|
174
|
-
*/
|
|
175
|
-
export enum MessagePriority {
|
|
176
|
-
/**
|
|
177
|
-
* Unknown priority, this will be returned as the default on non-android platforms
|
|
178
|
-
*/
|
|
179
|
-
PRIORITY_UNKNOWN = 0,
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* High priority - Activities may start foreground services if they receive high priority messages
|
|
183
|
-
*/
|
|
184
|
-
PRIORITY_HIGH = 1,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Normal priority - Activities have restrictions and may only perform unobtrusive actions on receipt
|
|
188
|
-
*/
|
|
189
|
-
PRIORITY_NORMAL = 2,
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Options for features provided by the FCM SDK for Web.
|
|
194
|
-
*/
|
|
195
|
-
export interface FcmOptions {
|
|
196
|
-
/**
|
|
197
|
-
* The link to open when the user clicks on the notification.
|
|
198
|
-
*/
|
|
199
|
-
link?: string;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* The label associated with the message's analytics data.
|
|
203
|
-
*/
|
|
204
|
-
analyticsLabel?: string;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Options for `getToken()` and `deleteToken()`
|
|
209
|
-
*/
|
|
210
|
-
export interface NativeTokenOptions {
|
|
211
|
-
/**
|
|
212
|
-
* The app name of the FirebaseApp instance.
|
|
213
|
-
*
|
|
214
|
-
* @platform android Android
|
|
215
|
-
*/
|
|
216
|
-
appName?: string;
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* The senderID for a particular Firebase project.
|
|
220
|
-
*
|
|
221
|
-
* @platform ios iOS
|
|
222
|
-
*/
|
|
223
|
-
senderId?: string;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Options for `getToken()`
|
|
228
|
-
*/
|
|
229
|
-
export interface GetTokenOptions {
|
|
230
|
-
/**
|
|
231
|
-
* The VAPID key used to authenticate the push subscribers
|
|
232
|
-
* to receive push messages only from sending servers
|
|
233
|
-
* that hold the corresponding private key.
|
|
234
|
-
*
|
|
235
|
-
* @platform web
|
|
236
|
-
*/
|
|
237
|
-
vapidKey?: string;
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* The service worker registration for receiving push messaging.
|
|
241
|
-
* If the registration is not provided explicitly, you need to
|
|
242
|
-
* have a firebase-messaging-sw.js at your root location.
|
|
243
|
-
*
|
|
244
|
-
* @platform web
|
|
245
|
-
*/
|
|
246
|
-
serviceWorkerRegistration?: ServiceWorkerRegistration;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* NotificationPayload is an alias for Notification. This is to keep it the same as
|
|
251
|
-
* Firebase Web JS SDK v9 and to make it backwards compatible.
|
|
252
|
-
*/
|
|
253
|
-
type NotificationPayload = Notification;
|
|
254
|
-
|
|
255
|
-
export interface Notification {
|
|
256
|
-
/**
|
|
257
|
-
* The native localization key for the notification title.
|
|
258
|
-
*/
|
|
259
|
-
titleLocKey?: string;
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Any arguments that should be formatted into the resource specified by titleLocKey.
|
|
263
|
-
*/
|
|
264
|
-
titleLocArgs?: string[];
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* The notification body content.
|
|
268
|
-
*/
|
|
269
|
-
body?: string;
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Web only. The URL to use for the notification's icon. If you don't send this key in the request,
|
|
273
|
-
* FCM displays the launcher icon specified in your app manifest.
|
|
274
|
-
*/
|
|
275
|
-
icon?: string;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Web only. The URL of an image that is downloaded on the device and displayed in the notification.
|
|
279
|
-
*/
|
|
280
|
-
image?: string;
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Web only. The notification's title.
|
|
284
|
-
*/
|
|
285
|
-
title?: string;
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* The native localization key for the notification body content.
|
|
289
|
-
*/
|
|
290
|
-
bodyLocKey?: string;
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Any arguments that should be formatted into the resource specified by bodyLocKey.
|
|
294
|
-
*/
|
|
295
|
-
bodyLocArgs?: string[];
|
|
296
|
-
|
|
297
|
-
ios?: {
|
|
298
|
-
/**
|
|
299
|
-
* The notification's subtitle.
|
|
300
|
-
*/
|
|
301
|
-
subtitle?: string;
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* The native localization key for the notification's subtitle.
|
|
305
|
-
*/
|
|
306
|
-
subtitleLocKey?: string;
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Any arguments that should be formatted into the resource specified by subtitleLocKey.
|
|
310
|
-
*/
|
|
311
|
-
subtitleLocArgs?: string[];
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* The value of the badge on the home screen app icon.
|
|
315
|
-
* If not specified, the badge is not changed.
|
|
316
|
-
* If set to 0, the badge has been removed.
|
|
317
|
-
*/
|
|
318
|
-
badge?: string;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* The sound played when the notification was delivered on the device (if permissions permit).
|
|
322
|
-
*/
|
|
323
|
-
sound?: string | NotificationIOSCriticalSound;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Additional Android specific properties set on the notification.
|
|
328
|
-
*/
|
|
329
|
-
android?: {
|
|
330
|
-
/**
|
|
331
|
-
* The sound played when the notification was delivered on the device (channel settings permitted).
|
|
332
|
-
*
|
|
333
|
-
* Set as "default" if the default device notification sound was used.
|
|
334
|
-
*/
|
|
335
|
-
sound?: string;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* The channel ID set on the notification. If not set, the notification uses the default
|
|
339
|
-
* "Miscellaneous" channel set by FCM.
|
|
340
|
-
*/
|
|
341
|
-
channelId?: string;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* The custom color used to tint the notification content.
|
|
345
|
-
*/
|
|
346
|
-
color?: string;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* The custom small icon used to display on the notification. If not set, uses the default
|
|
350
|
-
* application icon defined in the AndroidManifest file.
|
|
351
|
-
*/
|
|
352
|
-
smallIcon?: string;
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* The custom image was provided and displayed in the notification body.
|
|
356
|
-
*/
|
|
357
|
-
imageUrl?: string;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Deep link URL provided to the notification.
|
|
361
|
-
*/
|
|
362
|
-
link?: string;
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* The current unread notification count for this application, managed by the device.
|
|
366
|
-
*/
|
|
367
|
-
count?: number;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Name of the click action set on the notification.
|
|
371
|
-
*/
|
|
372
|
-
clickAction?: string;
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* The notification priority.
|
|
376
|
-
*
|
|
377
|
-
* Note; on devices which have channel support (Android 8.0 (API level 26) +),
|
|
378
|
-
* this value will be ignored. Instead, the channel "importance" level is used.
|
|
379
|
-
*/
|
|
380
|
-
priority?:
|
|
381
|
-
| NotificationAndroidPriority.PRIORITY_MIN
|
|
382
|
-
| NotificationAndroidPriority.PRIORITY_LOW
|
|
383
|
-
| NotificationAndroidPriority.PRIORITY_DEFAULT
|
|
384
|
-
| NotificationAndroidPriority.PRIORITY_HIGH
|
|
385
|
-
| NotificationAndroidPriority.PRIORITY_MAX;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Ticker text set on the notification.
|
|
389
|
-
*
|
|
390
|
-
* Ticker text is used for devices with accessibility enabled (e.g. to read out the message).
|
|
391
|
-
*/
|
|
392
|
-
ticker?: string;
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* The visibility of a notification. This value determines how the notification is shown on the users
|
|
396
|
-
* devices (e.g. on the lock-screen).
|
|
397
|
-
*/
|
|
398
|
-
visibility?:
|
|
399
|
-
| NotificationAndroidVisibility.VISIBILITY_SECRET
|
|
400
|
-
| NotificationAndroidVisibility.VISIBILITY_PRIVATE
|
|
401
|
-
| NotificationAndroidVisibility.VISIBILITY_PUBLIC;
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Represents a critical sound configuration that can be included in the
|
|
407
|
-
* `aps` dictionary of an APNs payload.
|
|
408
|
-
*/
|
|
409
|
-
export interface NotificationIOSCriticalSound {
|
|
410
|
-
/**
|
|
411
|
-
* The critical alert flag. Set to `true` to enable the critical alert.
|
|
412
|
-
*/
|
|
413
|
-
critical?: boolean;
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* The name of a sound file in the app's main bundle or in the `Library/Sounds`
|
|
417
|
-
* folder of the app's container directory. Specify the string "default" to play
|
|
418
|
-
* the system sound.
|
|
419
|
-
*/
|
|
420
|
-
name: string;
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* The volume for the critical alert's sound. Must be a value between 0.0
|
|
424
|
-
* (silent) and 1.0 (full volume).
|
|
425
|
-
*/
|
|
426
|
-
volume?: number;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* The enum representing a notification priority.
|
|
431
|
-
*
|
|
432
|
-
* Note; on devices which have channel support (Android 8.0 (API level 26) +),
|
|
433
|
-
* this value will be ignored. Instead, the channel "importance" level is used.
|
|
434
|
-
*
|
|
435
|
-
* Example:
|
|
436
|
-
*
|
|
437
|
-
* ```js
|
|
438
|
-
* firebase.messaging.NotificationAndroidPriority.PRIORITY_MIN;
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
export enum NotificationAndroidPriority {
|
|
442
|
-
/**
|
|
443
|
-
The application small icon will not show up in the status bar, or alert the user. The notification
|
|
444
|
-
will be in a collapsed state in the notification shade and placed at the bottom of the list.
|
|
445
|
-
*/
|
|
446
|
-
PRIORITY_MIN = -2,
|
|
447
|
-
|
|
448
|
-
/**
|
|
449
|
-
* The application small icon will show in the device status bar, however the notification will
|
|
450
|
-
* not alert the user (no sound or vibration). The notification will show in it's expanded state
|
|
451
|
-
* when the notification shade is pulled down.
|
|
452
|
-
*/
|
|
453
|
-
PRIORITY_LOW = -1,
|
|
454
|
-
|
|
455
|
-
/**
|
|
456
|
-
* When a notification is received, the device smallIcon will appear in the notification shade.
|
|
457
|
-
* When the user pulls down the notification shade, the content of the notification will be shown
|
|
458
|
-
* in it's expanded state.
|
|
459
|
-
*/
|
|
460
|
-
PRIORITY_DEFAULT = 0,
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Notifications will appear on-top of applications, allowing direct interaction without pulling
|
|
464
|
-
* own the notification shade. This level is used for urgent notifications, such as
|
|
465
|
-
* incoming phone calls, messages etc, which require immediate attention.
|
|
466
|
-
*/
|
|
467
|
-
PRIORITY_HIGH = 1,
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* The priority highest level a notification can be set at.
|
|
471
|
-
*/
|
|
472
|
-
PRIORITY_MAX = 2,
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* The enum representing the visibility of a notification.
|
|
477
|
-
*
|
|
478
|
-
* Example:
|
|
479
|
-
*
|
|
480
|
-
* ```js
|
|
481
|
-
* firebase.messaging.NotificationAndroidVisibility.VISIBILITY_SECRET;
|
|
482
|
-
* ```
|
|
483
|
-
*/
|
|
484
|
-
export enum NotificationAndroidVisibility {
|
|
485
|
-
/**
|
|
486
|
-
* Do not reveal any part of this notification on a secure lock-screen.
|
|
487
|
-
*/
|
|
488
|
-
VISIBILITY_SECRET = -1,
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* Show this notification on all lock-screens, but conceal sensitive or private information on secure lock-screens.
|
|
492
|
-
*/
|
|
493
|
-
VISIBILITY_PRIVATE = 0,
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* Show this notification in its entirety on all lock-screens.
|
|
497
|
-
*/
|
|
498
|
-
VISIBILITY_PUBLIC = 1,
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* An interface representing all the available permissions that can be requested by your app via
|
|
503
|
-
* the `requestPermission` API.
|
|
504
|
-
*/
|
|
505
|
-
export interface IOSPermissions {
|
|
506
|
-
/**
|
|
507
|
-
* Request permission to display alerts.
|
|
508
|
-
*
|
|
509
|
-
* Defaults to true.
|
|
510
|
-
*/
|
|
511
|
-
alert?: boolean;
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Request permission for Siri to automatically read out notification messages over AirPods.
|
|
515
|
-
*
|
|
516
|
-
* Defaults to false.
|
|
517
|
-
*
|
|
518
|
-
* @platform ios iOS >= 13
|
|
519
|
-
*/
|
|
520
|
-
announcement?: boolean;
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* Request permission to update the application badge.
|
|
524
|
-
*
|
|
525
|
-
* Defaults to true.
|
|
526
|
-
*/
|
|
527
|
-
badge?: boolean;
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* Request permission for critical alerts.
|
|
531
|
-
*
|
|
532
|
-
* Defaults to false.
|
|
533
|
-
*/
|
|
534
|
-
criticalAlert?: boolean;
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* Request permission to display notifications in a CarPlay environment.
|
|
538
|
-
*
|
|
539
|
-
* Defaults to true.
|
|
540
|
-
*/
|
|
541
|
-
carPlay?: boolean;
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Request permission to provisionally create non-interrupting notifications.
|
|
545
|
-
*
|
|
546
|
-
* Defaults to false.
|
|
547
|
-
*
|
|
548
|
-
* @platform ios iOS >= 12
|
|
549
|
-
*/
|
|
550
|
-
provisional?: boolean;
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Request permission to play sounds.
|
|
554
|
-
*
|
|
555
|
-
* Defaults to true.
|
|
556
|
-
*/
|
|
557
|
-
sound?: boolean;
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Request permission to display a button for in-app notification settings.
|
|
561
|
-
*
|
|
562
|
-
* Default to false
|
|
563
|
-
*
|
|
564
|
-
* @platform ios iOS >= 12
|
|
565
|
-
*/
|
|
566
|
-
providesAppNotificationSettings?: boolean;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* An enum representing the notification authorization status for this app on the device.
|
|
571
|
-
*
|
|
572
|
-
* Value is truthy if authorized, compare against an exact status (e.g. iOS PROVISIONAL) for a more
|
|
573
|
-
* granular status.
|
|
574
|
-
*
|
|
575
|
-
* Example:
|
|
576
|
-
*
|
|
577
|
-
* ```js
|
|
578
|
-
* firebase.messaging.AuthorizationStatus.NOT_DETERMINED;
|
|
579
|
-
* ```
|
|
580
|
-
*/
|
|
581
|
-
export enum AuthorizationStatus {
|
|
582
|
-
/**
|
|
583
|
-
* The app user has not yet chosen whether to allow the application to create notifications. Usually
|
|
584
|
-
* this status is returned prior to the first call of `requestPermission`.
|
|
585
|
-
*
|
|
586
|
-
* @platform ios iOS
|
|
587
|
-
*/
|
|
588
|
-
NOT_DETERMINED = -1,
|
|
589
|
-
|
|
590
|
-
/**
|
|
591
|
-
* The app is not authorized to create notifications.
|
|
592
|
-
*/
|
|
593
|
-
DENIED = 0,
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* The app is authorized to create notifications.
|
|
597
|
-
*/
|
|
598
|
-
AUTHORIZED = 1,
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* The app is currently authorized to post non-interrupting user notifications
|
|
602
|
-
* @platform ios iOS >= 12
|
|
603
|
-
*/
|
|
604
|
-
PROVISIONAL = 2,
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* The app is authorized to create notifications for a limited amount of time.
|
|
608
|
-
* Used in App Clips.
|
|
609
|
-
* @platform ios iOS >= 14
|
|
610
|
-
*/
|
|
611
|
-
EPHEMERAL = 3,
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* An event that is received when a message fails to send.
|
|
616
|
-
*
|
|
617
|
-
* ### Example
|
|
618
|
-
*
|
|
619
|
-
* ```js
|
|
620
|
-
* firebase.messaging().onSendError(event => {
|
|
621
|
-
* console.log(event.messageId);
|
|
622
|
-
* console.log(event.error);
|
|
623
|
-
* });
|
|
624
|
-
*/
|
|
625
|
-
export interface SendErrorEvent {
|
|
626
|
-
/**
|
|
627
|
-
* The id of the message that failed to send
|
|
628
|
-
*/
|
|
629
|
-
messageId: string;
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* A native firebase error that indicates the failure reason.
|
|
633
|
-
*/
|
|
634
|
-
error: NativeFirebaseError;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* The Firebase Messaging service interface.
|
|
639
|
-
*
|
|
640
|
-
* > This module is available for the default app only.
|
|
641
|
-
*
|
|
642
|
-
* #### Example
|
|
643
|
-
*
|
|
644
|
-
* Get the Messaging service for the default app:
|
|
645
|
-
*
|
|
646
|
-
* ```js
|
|
647
|
-
* const defaultAppMessaging = firebase.messaging();
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
export class Module extends FirebaseModule {
|
|
651
|
-
/**
|
|
652
|
-
* Returns whether messaging auto initialization is enabled or disabled for the device.
|
|
653
|
-
*
|
|
654
|
-
* #### Example
|
|
655
|
-
*
|
|
656
|
-
* ```js
|
|
657
|
-
* const isAutoInitEnabled = firebase.messaging().isAutoInitEnabled;
|
|
658
|
-
* ```
|
|
659
|
-
*/
|
|
660
|
-
isAutoInitEnabled: boolean;
|
|
661
|
-
|
|
662
|
-
/**
|
|
663
|
-
* Sets whether auto initialization for messaging is enabled or disabled.
|
|
664
|
-
*
|
|
665
|
-
* Set this to false to allow for an 'opt-in-first' flow for your users. By default auto
|
|
666
|
-
* initialization is enabled, which updates the device identifier and configuration data needed
|
|
667
|
-
* for messaging to Firebase.
|
|
668
|
-
*
|
|
669
|
-
* To ensure first app opens have an initial value set, set the argument in the `firebase.json`
|
|
670
|
-
* config.
|
|
671
|
-
*
|
|
672
|
-
* #### Example
|
|
673
|
-
*
|
|
674
|
-
* ```js
|
|
675
|
-
* // Disable auto initialization
|
|
676
|
-
* await firebase.messaging().setAutoInitEnabled(false);
|
|
677
|
-
* ```
|
|
678
|
-
*
|
|
679
|
-
* @param enabled A boolean value to enable or disable auto initialization.
|
|
680
|
-
*/
|
|
681
|
-
setAutoInitEnabled(enabled: boolean): Promise<void>;
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* When a notification from FCM has triggered the application to open from a quit state,
|
|
685
|
-
* this method will return a `RemoteMessage` containing the notification data, or `null` if
|
|
686
|
-
* the app was opened via another method.
|
|
687
|
-
*
|
|
688
|
-
* See `onNotificationOpenedApp` to subscribe to when the notification is opened when the app
|
|
689
|
-
* is in a background state.
|
|
690
|
-
*
|
|
691
|
-
* Beware of this [issue](https://github.com/invertase/react-native-firebase/issues/3469#issuecomment-660121376) when integrating with splash screen modules. If you are using
|
|
692
|
-
* `react-native-splash-screen` we strongly recommend you migrate to `react-native-bootsplash`
|
|
693
|
-
* which is actively maintained and avoids these issues
|
|
694
|
-
*/
|
|
695
|
-
getInitialNotification(): Promise<RemoteMessage | null>;
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* When the app is opened from iOS notifications settings from a quit state,
|
|
699
|
-
* this method will return `true` or `false` if the app was opened via another method.
|
|
700
|
-
*
|
|
701
|
-
* See `setOpenSettingsForNotificationsHandler` to subscribe to when the notificiation is opened when the app
|
|
702
|
-
* is in background state.
|
|
703
|
-
*
|
|
704
|
-
* @ios iOS >= 12
|
|
705
|
-
*/
|
|
706
|
-
getDidOpenSettingsForNotification(): Promise<boolean>;
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* Returns an FCM token for this device. Optionally you can specify a custom options to your own use-case.
|
|
710
|
-
*
|
|
711
|
-
* It is recommended you call this method on app start and update your backend with the new token.
|
|
712
|
-
*
|
|
713
|
-
* On iOS you'll need to register for remote notifications before calling this method, you can do
|
|
714
|
-
* this by calling `registerDeviceForRemoteMessages` or `requestPermission` as part of your app
|
|
715
|
-
* startup. If you have not registered and you call this method you will receive an 'unregistered'
|
|
716
|
-
* error code.
|
|
717
|
-
*
|
|
718
|
-
* #### Example - Default token
|
|
719
|
-
*
|
|
720
|
-
* ```js
|
|
721
|
-
* await firebase.messaging().registerDeviceForRemoteMessages();
|
|
722
|
-
* const fcmToken = await firebase.messaging().getToken();
|
|
723
|
-
*
|
|
724
|
-
* // Update backend (e.g. Firestore) with our token for the user
|
|
725
|
-
* const uid = firebase.auth().currentUser.uid;
|
|
726
|
-
* await firebase.firestore().doc(`users/${uid}`)
|
|
727
|
-
* .update({
|
|
728
|
-
* fcmTokens: firebase.firestore.FieldValues.arrayUnion(fcmToken),
|
|
729
|
-
* });
|
|
730
|
-
* ```
|
|
731
|
-
* @param options Options composite type with all members of `GetTokenOptions` and `NativeTokenOptions`
|
|
732
|
-
*/
|
|
733
|
-
getToken(options?: GetTokenOptions & NativeTokenOptions): Promise<string>;
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Returns whether the root view is headless or not
|
|
737
|
-
* i.e true if the app was launched in the background (for example, by data-only cloud message)
|
|
738
|
-
*
|
|
739
|
-
* More info: https://rnfirebase.io/messaging/usage#background-application-state
|
|
740
|
-
* @platform ios iOS
|
|
741
|
-
*/
|
|
742
|
-
getIsHeadless(): Promise<boolean>;
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Removes access to an FCM token previously authorized by it's scope. Messages sent by the server
|
|
746
|
-
* to this token will fail.
|
|
747
|
-
*
|
|
748
|
-
* #### Example
|
|
749
|
-
*
|
|
750
|
-
* ```js
|
|
751
|
-
* await firebase.messaging().deleteToken();
|
|
752
|
-
* ```
|
|
753
|
-
*
|
|
754
|
-
* @param options Options to override senderId (iOS) and appName (android)
|
|
755
|
-
*/
|
|
756
|
-
deleteToken(options?: NativeTokenOptions): Promise<void>;
|
|
757
|
-
|
|
758
|
-
/**
|
|
759
|
-
* When any FCM payload is received, the listener callback is called with a `RemoteMessage`.
|
|
760
|
-
*
|
|
761
|
-
* Returns an unsubscribe function to stop listening for new messages.
|
|
762
|
-
*
|
|
763
|
-
* #### Example
|
|
764
|
-
*
|
|
765
|
-
* ```js
|
|
766
|
-
* const unsubscribe = firebase.messaging().onMessage(async (remoteMessage) => {
|
|
767
|
-
* console.log('FCM Message Data:', remoteMessage.data);
|
|
768
|
-
*
|
|
769
|
-
* // Update a users messages list using AsyncStorage
|
|
770
|
-
* const currentMessages = await AsyncStorage.getItem('messages');
|
|
771
|
-
* const messageArray = JSON.parse(currentMessages);
|
|
772
|
-
* messageArray.push(remoteMessage.data);
|
|
773
|
-
* await AsyncStorage.setItem('messages', JSON.stringify(messageArray));
|
|
774
|
-
* });
|
|
775
|
-
*
|
|
776
|
-
* // Unsubscribe from further message events
|
|
777
|
-
* unsubscribe();
|
|
778
|
-
* ```
|
|
779
|
-
*
|
|
780
|
-
* > This subscriber method is only called when the app is active (in the foreground).
|
|
781
|
-
*
|
|
782
|
-
* @param listener Called with a `RemoteMessage` when a new FCM payload is received from the server.
|
|
783
|
-
*/
|
|
784
|
-
onMessage(listener: (message: RemoteMessage) => any): () => void;
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* When the user presses a notification displayed via FCM, this listener will be called if the app
|
|
788
|
-
* has opened from a background state.
|
|
789
|
-
*
|
|
790
|
-
* See `getInitialNotification` to see how to watch for when a notification opens the app from a
|
|
791
|
-
* quit state.
|
|
792
|
-
*
|
|
793
|
-
* Beware of this [issue](https://github.com/invertase/react-native-firebase/issues/3469#issuecomment-660121376) when integrating with splash screen modules. If you are using
|
|
794
|
-
* `react-native-splash-screen` we strongly recommend you migrate to `react-native-bootsplash`
|
|
795
|
-
* which is actively maintained and avoids these issues
|
|
796
|
-
*
|
|
797
|
-
* @param listener Called with a `RemoteMessage` when a notification press opens the application.
|
|
798
|
-
*/
|
|
799
|
-
onNotificationOpenedApp(listener: (message: RemoteMessage) => any): () => void;
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Called when a new registration token is generated for the device. For example, this event can happen when a
|
|
803
|
-
* token expires or when the server invalidates the token.
|
|
804
|
-
*
|
|
805
|
-
* Your app should always subscribe to this event and update your backend to ensure your device will
|
|
806
|
-
* receive new messages. The listener is only called when the app is active (in foreground), so ensure
|
|
807
|
-
* you call `getToken()` on app open to handle any new tokens generated when the app was not active.
|
|
808
|
-
*
|
|
809
|
-
* Returns an unsubscribe function to stop listening for token refresh events.
|
|
810
|
-
*
|
|
811
|
-
* #### Example
|
|
812
|
-
*
|
|
813
|
-
* ```js
|
|
814
|
-
* const unsubscribe = firebase.messaging().onTokenRefresh(async (fcmToken) => {
|
|
815
|
-
* console.log('New FCM Token:', fcmToken);
|
|
816
|
-
*
|
|
817
|
-
* // Append the database with the users new FCM token (e.g. with Firestore)
|
|
818
|
-
* const uid = firebase.auth().currentUser.uid;
|
|
819
|
-
* await firebase.firestore().doc(`users/${uid}`)
|
|
820
|
-
* .update({
|
|
821
|
-
* fcmTokens: firebase.firestore.FieldValues.arrayUnion(fcmToken),
|
|
822
|
-
* });
|
|
823
|
-
* });
|
|
824
|
-
* ```
|
|
825
|
-
*
|
|
826
|
-
* > This subscriber method is only called when the app is active (in the foreground).
|
|
827
|
-
*
|
|
828
|
-
* @param listener Called with a FCM token when the token is refreshed.
|
|
829
|
-
*/
|
|
830
|
-
onTokenRefresh(listener: (token: string) => any): () => void;
|
|
831
|
-
|
|
832
|
-
/**
|
|
833
|
-
* On iOS, messaging permission must be requested by the current application before messages can
|
|
834
|
-
* be received or sent.
|
|
835
|
-
*
|
|
836
|
-
* On iOS < 12, a modal will be shown to the user requesting messaging permissions for the app.
|
|
837
|
-
* Once handled, the promise will resolve with `AuthorizationStatus.AUTHORIZED` if permission was granted.
|
|
838
|
-
*
|
|
839
|
-
* On iOS >= 12, the app will be granted [Provisional Authorization](http://iosbrain.com/blog/2018/07/05/new-in-ios-12-implementing-provisional-authorization-for-quiet-notifications-in-swift/),
|
|
840
|
-
* and will resolve `AuthorizationStatus.AUTHORIZED`. The user will be able to receive FCM payloads and Notifications immediately;
|
|
841
|
-
* but notifications will be displayed silently. The user, through Notification Center, then has the option of upgrading your apps notifications to no longer be silent.
|
|
842
|
-
*
|
|
843
|
-
* > You can safely call this method on Android without platform checks. It's a no-op on Android and will promise resolve `AuthorizationStatus.AUTHORIZED`.
|
|
844
|
-
*
|
|
845
|
-
* #### Example
|
|
846
|
-
*
|
|
847
|
-
* ```js
|
|
848
|
-
* const authorizationStatus = await firebase.messaging().requestPermission();
|
|
849
|
-
* ```
|
|
850
|
-
*
|
|
851
|
-
* @ios
|
|
852
|
-
*/
|
|
853
|
-
requestPermission(permissions?: IOSPermissions): Promise<AuthorizationStatus>;
|
|
854
|
-
/**
|
|
855
|
-
* On iOS, if your app wants to receive remote messages from FCM (via APNs), you must explicitly register
|
|
856
|
-
* with APNs if auto-registration has been disabled.
|
|
857
|
-
*
|
|
858
|
-
* > You can safely call this method on Android without platform checks. It's a no-op on Android and will promise resolve `void`.
|
|
859
|
-
*
|
|
860
|
-
* > You can safely call this method multiple times, if the app is already registered then this method resolves immediately.
|
|
861
|
-
*
|
|
862
|
-
* #### Example
|
|
863
|
-
*
|
|
864
|
-
* ```js
|
|
865
|
-
* if (!firebase.messaging().isDeviceRegisteredForRemoteMessages) {
|
|
866
|
-
* await firebase.messaging().registerDeviceForRemoteMessages();
|
|
867
|
-
* }
|
|
868
|
-
* ```
|
|
869
|
-
*/
|
|
870
|
-
registerDeviceForRemoteMessages(): Promise<void>;
|
|
871
|
-
/**
|
|
872
|
-
* Returns a boolean value whether the user has registered for remote notifications via
|
|
873
|
-
* `registerDeviceForRemoteMessages()`.
|
|
874
|
-
*
|
|
875
|
-
* > You can safely access this property on Android without platform checks. Android returns `true` only.
|
|
876
|
-
*
|
|
877
|
-
* #### Example
|
|
878
|
-
*
|
|
879
|
-
* ```js
|
|
880
|
-
* const isDeviceRegisteredForRemoteMessages = firebase.messaging().isDeviceRegisteredForRemoteMessages;
|
|
881
|
-
* ```
|
|
882
|
-
*
|
|
883
|
-
* @platform ios
|
|
884
|
-
*/
|
|
885
|
-
isDeviceRegisteredForRemoteMessages: boolean;
|
|
886
|
-
/**
|
|
887
|
-
* Unregisters the app from receiving remote notifications.
|
|
888
|
-
*
|
|
889
|
-
* > You can safely call this method on Android without platform checks. It's a no-op on Android and will promise resolve `void`.
|
|
890
|
-
*
|
|
891
|
-
* #### Example
|
|
892
|
-
*
|
|
893
|
-
* ```js
|
|
894
|
-
* if (firebase.messaging().isDeviceRegisteredForRemoteMessages) {
|
|
895
|
-
* await firebase.messaging().unregisterDeviceForRemoteMessages();
|
|
896
|
-
* }
|
|
897
|
-
* ```
|
|
898
|
-
*
|
|
899
|
-
* @platform ios
|
|
900
|
-
*/
|
|
901
|
-
unregisterDeviceForRemoteMessages(): Promise<void>;
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* On iOS, it is possible to get the users APNs token. This may be required if you want to send messages to your
|
|
905
|
-
* iOS devices without using the FCM service.
|
|
906
|
-
*
|
|
907
|
-
* > You can safely call this method on Android without platform checks. It's a no-op on Android and will promise resolve `null`.
|
|
908
|
-
*
|
|
909
|
-
* #### Example
|
|
910
|
-
*
|
|
911
|
-
* ```js
|
|
912
|
-
* const apnsToken = await firebase.messaging().getAPNSToken();
|
|
913
|
-
*
|
|
914
|
-
* if (apnsToken) {
|
|
915
|
-
* console.log('User APNs Token:', apnsToken);
|
|
916
|
-
* }
|
|
917
|
-
* ```
|
|
918
|
-
*
|
|
919
|
-
* @platform ios
|
|
920
|
-
*/
|
|
921
|
-
getAPNSToken(): Promise<string | null>;
|
|
922
|
-
|
|
923
|
-
/**
|
|
924
|
-
* On iOS, This method is used to set the APNs Token received by the application delegate.
|
|
925
|
-
* Note that the token is expected to be a hexadecimal string, as it is an NSData type in
|
|
926
|
-
* the underlying native firebase SDK, and raw data may only be passed as a string if it is
|
|
927
|
-
* hex encoded. Calling code is responsible for correct encoding, you should verify by comparing
|
|
928
|
-
* the results of `getAPNSToken()` with your token parameter to make sure they are equivalent
|
|
929
|
-
*
|
|
930
|
-
* Messaging uses method swizzling to ensure that the APNs token is set automatically.
|
|
931
|
-
* However, if you have disabled swizzling by setting FirebaseAppDelegateProxyEnabled to NO
|
|
932
|
-
* in your app’s Info.plist, you should manually set the APNs token in your application
|
|
933
|
-
* delegate’s application(_:didRegisterForRemoteNotificationsWithDeviceToken:) method.
|
|
934
|
-
*
|
|
935
|
-
* If you would like to set the type of the APNs token, rather than relying on automatic
|
|
936
|
-
* detection, provide a type of either 'prod', 'sandbox'. Omitting the type parameter
|
|
937
|
-
* or specifying 'unknown' will rely on automatic type detection based on provisioning profile.
|
|
938
|
-
*
|
|
939
|
-
* At a native level you may also call objective-c `[FIRMessaging setAPNSToken];` as needed
|
|
940
|
-
*
|
|
941
|
-
* > You can safely call this method on Android without platform checks. It's a no-op on Android and will promise resolve `null`.
|
|
942
|
-
*
|
|
943
|
-
* #### Example
|
|
944
|
-
*
|
|
945
|
-
* ```js
|
|
946
|
-
* let myAPNSToken = someOthermodule.someWayToGetAPNSToken();
|
|
947
|
-
* await firebase.messaging().setAPNSToken(myAPNSToken);
|
|
948
|
-
* ```
|
|
949
|
-
*
|
|
950
|
-
* @param token a hexadecimal string representing your APNS token
|
|
951
|
-
* @param type optional string specifying 'prod', 'sandbox' or 'unknown' token type
|
|
952
|
-
* @platform ios
|
|
953
|
-
*/
|
|
954
|
-
setAPNSToken(token: string, type?: string): Promise<void>;
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Returns a `AuthorizationStatus` as to whether the user has messaging permission for this app.
|
|
958
|
-
*
|
|
959
|
-
* #### Example
|
|
960
|
-
*
|
|
961
|
-
* ```js
|
|
962
|
-
* const authStatus = await firebase.messaging().hasPermission();
|
|
963
|
-
* if (authStatus === firebase.messaging.AuthorizationStatus.AUTHORIZED) {
|
|
964
|
-
* // yay
|
|
965
|
-
* }
|
|
966
|
-
*
|
|
967
|
-
* ```
|
|
968
|
-
*/
|
|
969
|
-
hasPermission(): Promise<AuthorizationStatus>;
|
|
970
|
-
|
|
971
|
-
/**
|
|
972
|
-
* Called when the FCM server deletes pending messages. This may be due to:
|
|
973
|
-
*
|
|
974
|
-
* 1. Too many messages stored on the FCM server. This can occur when an app's servers send a bunch
|
|
975
|
-
* of non-collapsible messages to FCM servers while the device is offline.
|
|
976
|
-
*
|
|
977
|
-
* 2. The device hasn't connected in a long time and the app server has recently (within the last
|
|
978
|
-
* 4 weeks) sent a message to the app on that device.
|
|
979
|
-
*
|
|
980
|
-
* It is recommended that the app do a full sync with the server after receiving this call (e.g.
|
|
981
|
-
* requesting all user messages from the database).
|
|
982
|
-
*
|
|
983
|
-
* Returns an unsubscribe function to stop listening for deleted messages.
|
|
984
|
-
*
|
|
985
|
-
* #### Example
|
|
986
|
-
*
|
|
987
|
-
* ```js
|
|
988
|
-
* const unsubscribe = firebase.messaging().onDeletedMessages(() => {
|
|
989
|
-
* // Perform a full app re-sync
|
|
990
|
-
* });
|
|
991
|
-
*
|
|
992
|
-
* // Unsubscribe from deleted messages events
|
|
993
|
-
* unsubscribe();
|
|
994
|
-
* ```
|
|
995
|
-
*
|
|
996
|
-
* NOTE: Android only
|
|
997
|
-
*
|
|
998
|
-
* @param listener Called when the FCM deletes pending messages.
|
|
999
|
-
*/
|
|
1000
|
-
onDeletedMessages(listener: () => void): () => void;
|
|
1001
|
-
|
|
1002
|
-
/**
|
|
1003
|
-
* When sending a `RemoteMessage`, this listener is called when the message has been sent to FCM.
|
|
1004
|
-
*
|
|
1005
|
-
* Returns an unsubscribe function to stop listening for sent messages.
|
|
1006
|
-
*
|
|
1007
|
-
* #### Example
|
|
1008
|
-
*
|
|
1009
|
-
* ```js
|
|
1010
|
-
* const unsubscribe = firebase.messaging().onMessageSent((messageId) => {
|
|
1011
|
-
* console.log('Message has been sent to the FCM server', messageId);
|
|
1012
|
-
* });
|
|
1013
|
-
*
|
|
1014
|
-
* // Unsubscribe from message sent events
|
|
1015
|
-
* unsubscribe();
|
|
1016
|
-
* ```
|
|
1017
|
-
*
|
|
1018
|
-
* NOTE: Android only
|
|
1019
|
-
*
|
|
1020
|
-
* @param listener Called when the FCM sends the remote message to FCM.
|
|
1021
|
-
*/
|
|
1022
|
-
onMessageSent(listener: (messageId: string) => any): () => void;
|
|
1023
|
-
|
|
1024
|
-
/**
|
|
1025
|
-
* When sending a `RemoteMessage`, this listener is called when an error is thrown and the
|
|
1026
|
-
* message could not be sent.
|
|
1027
|
-
*
|
|
1028
|
-
* Returns an unsubscribe function to stop listening for sent errors.
|
|
1029
|
-
*
|
|
1030
|
-
* #### Example
|
|
1031
|
-
*
|
|
1032
|
-
* ```js
|
|
1033
|
-
* const unsubscribe = firebase.messaging().onSendError(({ messageId, error }) => {
|
|
1034
|
-
* console.log('An error occurred when sending a message to FCM', messageId, error);
|
|
1035
|
-
* });
|
|
1036
|
-
*
|
|
1037
|
-
* // Unsubscribe from message sent error events
|
|
1038
|
-
* unsubscribe();
|
|
1039
|
-
* ```
|
|
1040
|
-
*
|
|
1041
|
-
* NOTE: Android only
|
|
1042
|
-
*
|
|
1043
|
-
* @param listener
|
|
1044
|
-
*/
|
|
1045
|
-
onSendError(listener: (evt: SendErrorEvent) => any): () => void;
|
|
1046
|
-
|
|
1047
|
-
/**
|
|
1048
|
-
* Set a message handler function which is called when the app is in the background
|
|
1049
|
-
* or terminated. In Android, a headless task is created, allowing you to access the React Native environment
|
|
1050
|
-
* to perform tasks such as updating local storage, or sending a network request.
|
|
1051
|
-
*
|
|
1052
|
-
* This method must be called **outside** of your application lifecycle, e.g. alongside your
|
|
1053
|
-
* `AppRegistry.registerComponent()` method call at the the entry point of your application code.
|
|
1054
|
-
*
|
|
1055
|
-
*
|
|
1056
|
-
* #### Example
|
|
1057
|
-
*
|
|
1058
|
-
* ```js
|
|
1059
|
-
* firebase.messaging().setBackgroundMessageHandler(async (remoteMessage) => {
|
|
1060
|
-
* // Update a users messages list using AsyncStorage
|
|
1061
|
-
* const currentMessages = await AsyncStorage.getItem('messages');
|
|
1062
|
-
* const messageArray = JSON.parse(currentMessages);
|
|
1063
|
-
* messageArray.push(remoteMessage.data);
|
|
1064
|
-
* await AsyncStorage.setItem('messages', JSON.stringify(messageArray));
|
|
1065
|
-
* });
|
|
1066
|
-
* ```
|
|
1067
|
-
*
|
|
1068
|
-
*/
|
|
1069
|
-
setBackgroundMessageHandler(handler: (message: RemoteMessage) => Promise<any>): void;
|
|
1070
|
-
|
|
1071
|
-
/**
|
|
1072
|
-
* Set a handler function which is called when the `${App Name} notifications settings`
|
|
1073
|
-
* link in iOS settings is clicked.
|
|
1074
|
-
*
|
|
1075
|
-
* This method must be called **outside** of your application lifecycle, e.g. alongside your
|
|
1076
|
-
* `AppRegistry.registerComponent()` method call at the the entry point of your application code.
|
|
1077
|
-
*
|
|
1078
|
-
* @ios iOS >= 12
|
|
1079
|
-
*/
|
|
1080
|
-
setOpenSettingsForNotificationsHandler(handler: (message: RemoteMessage) => any): void;
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
* Send a new `RemoteMessage` to the FCM server.
|
|
1084
|
-
*
|
|
1085
|
-
* The promise resolves when the message has been added to the internal queue. Use `onMessageSent()`
|
|
1086
|
-
* and `onSendError()` to determine when the message has been sent to the server.
|
|
1087
|
-
*
|
|
1088
|
-
* #### Example
|
|
1089
|
-
*
|
|
1090
|
-
* ```js
|
|
1091
|
-
* await firebase.messaging().sendMessage({
|
|
1092
|
-
* data: {
|
|
1093
|
-
* loggedIn: Date.now(),
|
|
1094
|
-
* uid: firebase.auth().currentUser.uid,
|
|
1095
|
-
* }
|
|
1096
|
-
* });
|
|
1097
|
-
* ```
|
|
1098
|
-
*
|
|
1099
|
-
* NOTE: Android only
|
|
1100
|
-
*
|
|
1101
|
-
* @param message A `RemoteMessage` interface.
|
|
1102
|
-
*/
|
|
1103
|
-
sendMessage(message: RemoteMessage): Promise<void>;
|
|
1104
|
-
|
|
1105
|
-
/**
|
|
1106
|
-
* Apps can subscribe to a topic, which allows the FCM server to send targeted messages to only those
|
|
1107
|
-
* devices subscribed to that topic.
|
|
1108
|
-
*
|
|
1109
|
-
* #### Example
|
|
1110
|
-
*
|
|
1111
|
-
* ```js
|
|
1112
|
-
* await firebase.messaging().subscribeToTopic('news');
|
|
1113
|
-
* ```
|
|
1114
|
-
*
|
|
1115
|
-
* @param topic The topic name.
|
|
1116
|
-
*/
|
|
1117
|
-
subscribeToTopic(topic: string): Promise<void>;
|
|
1118
|
-
|
|
1119
|
-
/**
|
|
1120
|
-
* Unsubscribe the device from a topic.
|
|
1121
|
-
*
|
|
1122
|
-
* #### Example
|
|
1123
|
-
*
|
|
1124
|
-
* ```js
|
|
1125
|
-
* await firebase.messaging().unsubscribeFromTopic('news');
|
|
1126
|
-
* ```
|
|
1127
|
-
*
|
|
1128
|
-
* @param topic The topic name.
|
|
1129
|
-
*/
|
|
1130
|
-
unsubscribeFromTopic(topic: string): Promise<void>;
|
|
1131
|
-
|
|
1132
|
-
/**
|
|
1133
|
-
* Sets whether message delivery metrics are exported to BigQuery is enabled or disabled.
|
|
1134
|
-
*
|
|
1135
|
-
* The value is false by default. Set this to true to allow exporting of message delivery metrics to BigQuery.
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* #### Example
|
|
1139
|
-
*
|
|
1140
|
-
* ```js
|
|
1141
|
-
* // Enable exports of message delivery metrics to BigQuery
|
|
1142
|
-
* await firebase.messaging().setDeliveryMetricsExportToBigQuery(true);
|
|
1143
|
-
* ```
|
|
1144
|
-
*
|
|
1145
|
-
* @param enabled A boolean value to enable or disable exporting of message delivery metrics to BigQuery.
|
|
1146
|
-
*/
|
|
1147
|
-
setDeliveryMetricsExportToBigQuery(enabled: boolean): Promise<void>;
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* Sets whether remote notification delegation to Google Play Services is enabled or disabled.
|
|
1151
|
-
*
|
|
1152
|
-
* The value is false by default. Set this to true to allow remote notification delegation.
|
|
1153
|
-
*
|
|
1154
|
-
* Warning: this will disable notification handlers on Android, and on iOS it has no effect
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
* #### Example
|
|
1158
|
-
*
|
|
1159
|
-
* ```js
|
|
1160
|
-
* // Enable delegation of remote notifications to Google Play Services
|
|
1161
|
-
* await firebase.messaging().setNotificationDelegationEnabled(true);
|
|
1162
|
-
* ```
|
|
1163
|
-
*
|
|
1164
|
-
* @param enabled A boolean value to enable or disable remote notification delegation to Google Play Services.
|
|
1165
|
-
*/
|
|
1166
|
-
setNotificationDelegationEnabled(enabled: boolean): Promise<void>;
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* Gets whether remote notification delegation to Google Play Services is enabled or disabled.
|
|
1170
|
-
*
|
|
1171
|
-
* #### Example
|
|
1172
|
-
*
|
|
1173
|
-
* ```js
|
|
1174
|
-
* // Determine if delegation of remote notifications to Google Play Services is enabled
|
|
1175
|
-
* const delegationEnabled = await firebase.messaging().isNotificationDelegationEnabled();
|
|
1176
|
-
* ```
|
|
1177
|
-
*
|
|
1178
|
-
* @returns enabled A boolean value indicatign if remote notification delegation to Google Play Services is enabled.
|
|
1179
|
-
*/
|
|
1180
|
-
istNotificationDelegationEnabled(): Promise<boolean>;
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
* Checks if all required APIs exist in the browser.
|
|
1184
|
-
*
|
|
1185
|
-
* @web
|
|
1186
|
-
*/
|
|
1187
|
-
isSupported(): Promise<boolean>;
|
|
1188
|
-
|
|
1189
|
-
/**
|
|
1190
|
-
* Enables or disables Firebase Cloud Messaging message delivery metrics export to BigQuery. By
|
|
1191
|
-
* default, message delivery metrics are not exported to BigQuery. Use this method to enable or
|
|
1192
|
-
* disable the export at runtime.
|
|
1193
|
-
*
|
|
1194
|
-
* @web
|
|
1195
|
-
*/
|
|
1196
|
-
experimentalSetDeliveryMetricsExportedToBigQueryEnabled(): void;
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
declare const defaultExport: ReactNativeFirebase.FirebaseModuleWithStatics<
|
|
1201
|
-
FirebaseMessagingTypes.Module,
|
|
1202
|
-
FirebaseMessagingTypes.Statics
|
|
1203
|
-
>;
|
|
1204
|
-
|
|
1205
|
-
export const firebase: ReactNativeFirebase.Module & {
|
|
1206
|
-
messaging: typeof defaultExport;
|
|
1207
|
-
app(
|
|
1208
|
-
name?: string,
|
|
1209
|
-
): ReactNativeFirebase.FirebaseApp & { messaging(): FirebaseMessagingTypes.Module };
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
export default defaultExport;
|
|
1213
|
-
|
|
1214
|
-
/**
|
|
1215
|
-
* Attach namespace to `firebase.` and `FirebaseApp.`.
|
|
1216
|
-
*/
|
|
1217
|
-
declare module '@react-native-firebase/app' {
|
|
1218
|
-
namespace ReactNativeFirebase {
|
|
1219
|
-
import FirebaseModuleWithStatics = ReactNativeFirebase.FirebaseModuleWithStatics;
|
|
1220
|
-
interface Module {
|
|
1221
|
-
messaging: FirebaseModuleWithStatics<
|
|
1222
|
-
FirebaseMessagingTypes.Module,
|
|
1223
|
-
FirebaseMessagingTypes.Statics
|
|
1224
|
-
>;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
interface FirebaseApp {
|
|
1228
|
-
messaging(): FirebaseMessagingTypes.Module;
|
|
1229
|
-
}
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
export * from './modular';
|