@react-native-firebase/messaging 23.7.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.
Files changed (109) hide show
  1. package/dist/commonjs/index.js +61 -0
  2. package/dist/commonjs/index.js.map +1 -0
  3. package/dist/commonjs/modular.js +439 -0
  4. package/dist/commonjs/modular.js.map +1 -0
  5. package/dist/commonjs/namespaced.js +407 -0
  6. package/dist/commonjs/namespaced.js.map +1 -0
  7. package/dist/commonjs/package.json +1 -0
  8. package/dist/commonjs/remoteMessageOptions.js +87 -0
  9. package/dist/commonjs/remoteMessageOptions.js.map +1 -0
  10. package/dist/commonjs/statics.js +29 -0
  11. package/dist/commonjs/statics.js.map +1 -0
  12. package/dist/commonjs/types/messaging.js +105 -0
  13. package/dist/commonjs/types/messaging.js.map +1 -0
  14. package/dist/commonjs/version.js +9 -0
  15. package/dist/commonjs/version.js.map +1 -0
  16. package/{ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.h → dist/module/index.js} +11 -12
  17. package/dist/module/index.js.map +1 -0
  18. package/{lib/modular/index.js → dist/module/modular.js} +135 -119
  19. package/dist/module/modular.js.map +1 -0
  20. package/{lib/index.js → dist/module/namespaced.js} +70 -193
  21. package/dist/module/namespaced.js.map +1 -0
  22. package/dist/module/package.json +1 -0
  23. package/{lib → dist/module}/remoteMessageOptions.js +10 -27
  24. package/dist/module/remoteMessageOptions.js.map +1 -0
  25. package/dist/module/statics.js +25 -0
  26. package/dist/module/statics.js.map +1 -0
  27. package/dist/module/types/messaging.js +124 -0
  28. package/dist/module/types/messaging.js.map +1 -0
  29. package/dist/module/version.js +5 -0
  30. package/dist/module/version.js.map +1 -0
  31. package/dist/typescript/commonjs/lib/index.d.ts +6 -0
  32. package/dist/typescript/commonjs/lib/index.d.ts.map +1 -0
  33. package/{lib/modular/index.d.ts → dist/typescript/commonjs/lib/modular.d.ts} +86 -164
  34. package/dist/typescript/commonjs/lib/modular.d.ts.map +1 -0
  35. package/dist/typescript/commonjs/lib/namespaced.d.ts +12 -0
  36. package/dist/typescript/commonjs/lib/namespaced.d.ts.map +1 -0
  37. package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts +14 -0
  38. package/dist/typescript/commonjs/lib/remoteMessageOptions.d.ts.map +1 -0
  39. package/dist/typescript/commonjs/lib/statics.d.ts +20 -0
  40. package/dist/typescript/commonjs/lib/statics.d.ts.map +1 -0
  41. package/dist/typescript/commonjs/lib/types/messaging.d.ts +673 -0
  42. package/dist/typescript/commonjs/lib/types/messaging.d.ts.map +1 -0
  43. package/dist/typescript/commonjs/lib/version.d.ts +2 -0
  44. package/dist/typescript/commonjs/lib/version.d.ts.map +1 -0
  45. package/dist/typescript/commonjs/package.json +1 -0
  46. package/dist/typescript/module/lib/index.d.ts +6 -0
  47. package/dist/typescript/module/lib/index.d.ts.map +1 -0
  48. package/dist/typescript/module/lib/modular.d.ts +247 -0
  49. package/dist/typescript/module/lib/modular.d.ts.map +1 -0
  50. package/dist/typescript/module/lib/namespaced.d.ts +12 -0
  51. package/dist/typescript/module/lib/namespaced.d.ts.map +1 -0
  52. package/dist/typescript/module/lib/remoteMessageOptions.d.ts +14 -0
  53. package/dist/typescript/module/lib/remoteMessageOptions.d.ts.map +1 -0
  54. package/dist/typescript/module/lib/statics.d.ts +20 -0
  55. package/dist/typescript/module/lib/statics.d.ts.map +1 -0
  56. package/dist/typescript/module/lib/types/messaging.d.ts +673 -0
  57. package/dist/typescript/module/lib/types/messaging.d.ts.map +1 -0
  58. package/dist/typescript/module/lib/version.d.ts +2 -0
  59. package/dist/typescript/module/lib/version.d.ts.map +1 -0
  60. package/dist/typescript/module/package.json +1 -0
  61. package/{ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.h → lib/index.ts} +28 -21
  62. package/lib/modular.ts +447 -0
  63. package/lib/namespaced.ts +583 -0
  64. package/lib/remoteMessageOptions.ts +110 -0
  65. package/lib/{statics.js → statics.ts} +6 -3
  66. package/lib/types/messaging.ts +815 -0
  67. package/lib/version.ts +2 -0
  68. package/package.json +64 -8
  69. package/tsconfig.json +21 -0
  70. package/CHANGELOG.md +0 -1181
  71. package/RNFBMessaging.podspec +0 -50
  72. package/android/.editorconfig +0 -10
  73. package/android/build.gradle +0 -149
  74. package/android/lint.xml +0 -5
  75. package/android/settings.gradle +0 -1
  76. package/android/src/main/AndroidManifest.xml +0 -43
  77. package/android/src/main/java/io/invertase/firebase/messaging/JsonConvert.java +0 -127
  78. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingHeadlessService.java +0 -30
  79. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingModule.java +0 -332
  80. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingPackage.java +0 -41
  81. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingReceiver.java +0 -66
  82. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingSerializer.java +0 -225
  83. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingService.java +0 -37
  84. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStore.java +0 -15
  85. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreHelper.java +0 -23
  86. package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingStoreImpl.java +0 -97
  87. package/android/src/main/res/values/colors.xml +0 -143
  88. package/app.plugin.js +0 -1
  89. package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.h +0 -54
  90. package/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m +0 -251
  91. package/ios/RNFBMessaging/RNFBMessaging+FIRMessagingDelegate.m +0 -70
  92. package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.h +0 -29
  93. package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.m +0 -173
  94. package/ios/RNFBMessaging/RNFBMessaging+UNUserNotificationCenter.m +0 -185
  95. package/ios/RNFBMessaging/RNFBMessagingModule.h +0 -26
  96. package/ios/RNFBMessaging/RNFBMessagingModule.m +0 -431
  97. package/ios/RNFBMessaging/RNFBMessagingSerializer.h +0 -32
  98. package/ios/RNFBMessaging/RNFBMessagingSerializer.m +0 -235
  99. package/ios/RNFBMessaging.xcodeproj/project.pbxproj +0 -384
  100. package/ios/RNFBMessaging.xcodeproj/xcshareddata/IDETemplateMacros.plist +0 -24
  101. package/lib/index.d.ts +0 -1233
  102. package/lib/version.js +0 -2
  103. package/plugin/build/android/index.d.ts +0 -2
  104. package/plugin/build/android/index.js +0 -5
  105. package/plugin/build/android/setupFirebaseNotifationIcon.d.ts +0 -8
  106. package/plugin/build/android/setupFirebaseNotifationIcon.js +0 -62
  107. package/plugin/build/index.d.ts +0 -3
  108. package/plugin/build/index.js +0 -16
  109. package/plugin/tsconfig.tsbuildinfo +0 -1
@@ -1,4 +1,4 @@
1
- /**
1
+ /*
2
2
  * Copyright (c) 2016-present Invertase Limited & Contributors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,23 +15,30 @@
15
15
  *
16
16
  */
17
17
 
18
- #import <UserNotifications/UserNotifications.h>
19
-
20
- NS_ASSUME_NONNULL_BEGIN
21
-
22
- @interface RNFBMessagingUNUserNotificationCenter : NSObject <UNUserNotificationCenterDelegate>
23
-
24
- @property NSDictionary *_Nullable initialNotification;
25
- @property BOOL didOpenSettingsForNotification;
26
- @property(nonatomic, nullable, weak) id<UNUserNotificationCenterDelegate> originalDelegate;
27
-
28
- + (_Nonnull instancetype)sharedInstance;
29
-
30
- - (void)observe;
31
-
32
- - (nullable NSDictionary *)getInitialNotification;
33
-
34
- - (NSNumber *)getDidOpenSettingsForNotification;
35
- @end
36
-
37
- NS_ASSUME_NONNULL_END
18
+ // Export types from types/messaging
19
+ export type {
20
+ Messaging,
21
+ RemoteMessage,
22
+ MessagePriority,
23
+ FcmOptions,
24
+ NativeTokenOptions,
25
+ GetTokenOptions,
26
+ Notification,
27
+ NotificationIOSCriticalSound,
28
+ IOSPermissions,
29
+ SendErrorEvent,
30
+ FirebaseMessagingTypes,
31
+ } from './types/messaging';
32
+
33
+ export {
34
+ AuthorizationStatus,
35
+ NotificationAndroidPriority,
36
+ NotificationAndroidVisibility,
37
+ } from './statics';
38
+
39
+ // Export modular API functions
40
+ export * from './modular';
41
+
42
+ // Export namespaced API
43
+ export * from './namespaced';
44
+ export { default } from './namespaced';
package/lib/modular.ts ADDED
@@ -0,0 +1,447 @@
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 { getApp } from '@react-native-firebase/app';
19
+ import { withModularFlag } from '@react-native-firebase/app/lib/common';
20
+ import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/lib/common';
21
+ import type {
22
+ Messaging,
23
+ RemoteMessage,
24
+ NativeTokenOptions,
25
+ GetTokenOptions,
26
+ IOSPermissions,
27
+ AuthorizationStatus,
28
+ SendErrorEvent,
29
+ } from './types/messaging';
30
+ import type { ReactNativeFirebase } from '@react-native-firebase/app';
31
+
32
+ /**
33
+ * Returns a Messaging instance for the given app.
34
+ * @param app - FirebaseApp. Optional.
35
+ * @returns Messaging instance
36
+ */
37
+ export function getMessaging(app?: ReactNativeFirebase.FirebaseApp): Messaging {
38
+ if (app) {
39
+ return getApp(app.name).messaging();
40
+ }
41
+
42
+ return getApp().messaging();
43
+ }
44
+
45
+ /**
46
+ * Removes access to an FCM token previously authorized by its scope.
47
+ * Messages sent by the server to this token will fail.
48
+ * @param messaging - Messaging instance.
49
+ * @param tokenOptions - Options to override senderId (iOS) and projectId (Android).
50
+ * @returns Promise that resolves when the token is deleted.
51
+ */
52
+ export function deleteToken(
53
+ messaging: Messaging,
54
+ tokenOptions?: NativeTokenOptions,
55
+ ): Promise<void> {
56
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
57
+ return messaging.deleteToken.call(messaging, tokenOptions, MODULAR_DEPRECATION_ARG);
58
+ }
59
+
60
+ /**
61
+ * Returns an FCM token for this device. Optionally, you can specify custom options for your own use case.
62
+ * @param messaging - Messaging instance.
63
+ * @param options - Options to override senderId (iOS) and appName.
64
+ * @returns Promise that resolves with the FCM token.
65
+ */
66
+ export function getToken(
67
+ messaging: Messaging,
68
+ options?: GetTokenOptions & NativeTokenOptions,
69
+ ): Promise<string> {
70
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
71
+ return messaging.getToken.call(messaging, options, MODULAR_DEPRECATION_ARG);
72
+ }
73
+
74
+ /**
75
+ * When any FCM payload is received, the listener callback is called with a `RemoteMessage`.
76
+ * > This subscriber method is only called when the app is active (in the foreground).
77
+ * @param messaging - Messaging instance.
78
+ * @param listener - Called with a `RemoteMessage` when a new FCM payload is received from the server.
79
+ * @returns Function to unsubscribe from the message listener.
80
+ */
81
+ export function onMessage(
82
+ messaging: Messaging,
83
+ listener: (message: RemoteMessage) => any,
84
+ ): () => void {
85
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
86
+ return messaging.onMessage.call(messaging, listener, MODULAR_DEPRECATION_ARG);
87
+ }
88
+
89
+ /**
90
+ * When the user presses a notification displayed via FCM, this listener will be called if the app
91
+ * has opened from a background state.
92
+ * @param messaging - Messaging instance.
93
+ * @param listener - Called with a `RemoteMessage` when a notification press opens the application.
94
+ * @returns Function to unsubscribe from the notification opened listener.
95
+ */
96
+ export function onNotificationOpenedApp(
97
+ messaging: Messaging,
98
+ listener: (message: RemoteMessage) => any,
99
+ ): () => void {
100
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
101
+ return messaging.onNotificationOpenedApp.call(messaging, listener, MODULAR_DEPRECATION_ARG);
102
+ }
103
+
104
+ /**
105
+ * Called when a new registration token is generated for the device. For example, this event can happen when a
106
+ * token expires or when the server invalidates the token.
107
+ * > This subscriber method is only called when the app is active (in the foreground).
108
+ * @param messaging - Messaging instance.
109
+ * @param listener - Called with a FCM token when the token is refreshed.
110
+ * @returns Function to unsubscribe from the token refresh listener.
111
+ */
112
+ export function onTokenRefresh(messaging: Messaging, listener: (token: string) => any): () => void {
113
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
114
+ return messaging.onTokenRefresh.call(messaging, listener, MODULAR_DEPRECATION_ARG);
115
+ }
116
+
117
+ /**
118
+ * On iOS, messaging permission must be requested by the current application before messages can
119
+ * be received or sent.
120
+ * @param messaging - Messaging instance.
121
+ * @param iosPermissions - All the available permissions for iOS that can be requested.
122
+ * @returns Promise that resolves with the authorization status.
123
+ */
124
+ export function requestPermission(
125
+ messaging: Messaging,
126
+ iosPermissions?: IOSPermissions,
127
+ ): Promise<AuthorizationStatus> {
128
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
129
+ return messaging.requestPermission.call(messaging, iosPermissions, MODULAR_DEPRECATION_ARG);
130
+ }
131
+
132
+ /**
133
+ * Returns whether messaging auto initialization is enabled or disabled for the device.
134
+ * @param messaging - Messaging instance.
135
+ * @returns Boolean indicating whether auto initialization is enabled.
136
+ */
137
+ export function isAutoInitEnabled(messaging: Messaging): boolean {
138
+ return withModularFlag(() => messaging.isAutoInitEnabled);
139
+ }
140
+
141
+ /**
142
+ * Sets whether messaging auto initialization is enabled or disabled for the device.
143
+ * @param messaging - Messaging instance.
144
+ * @param enabled - A boolean value to enable or disable auto initialization.
145
+ * @returns Promise that resolves when the setting is updated.
146
+ */
147
+ export function setAutoInitEnabled(messaging: Messaging, enabled: boolean): Promise<void> {
148
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
149
+ return messaging.setAutoInitEnabled.call(messaging, enabled, MODULAR_DEPRECATION_ARG);
150
+ }
151
+
152
+ /**
153
+ * When a notification from FCM has triggered the application to open from a quit state,
154
+ * this method will return a `RemoteMessage` containing the notification data, or `null` if
155
+ * the app was opened via another method.
156
+ * @param messaging - Messaging instance.
157
+ * @returns Promise that resolves with the initial notification or null.
158
+ */
159
+ export function getInitialNotification(messaging: Messaging): Promise<RemoteMessage | null> {
160
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
161
+ return messaging.getInitialNotification.call(messaging, MODULAR_DEPRECATION_ARG);
162
+ }
163
+
164
+ /**
165
+ * When the app is opened from iOS notifications settings from a quit state,
166
+ * this method will return `true` or `false` if the app was opened via another method.
167
+ * @param messaging - Messaging instance.
168
+ * @returns Promise that resolves with a boolean indicating if the app was opened from settings.
169
+ */
170
+ export function getDidOpenSettingsForNotification(messaging: Messaging): Promise<boolean> {
171
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
172
+ return messaging.getDidOpenSettingsForNotification.call(messaging, MODULAR_DEPRECATION_ARG);
173
+ }
174
+
175
+ /**
176
+ * Returns whether the root view is headless or not
177
+ * i.e true if the app was launched in the background (for example, by data-only cloud message)
178
+ * @param messaging - Messaging instance.
179
+ * @returns Promise that resolves with a boolean indicating if the app is headless.
180
+ */
181
+ export function getIsHeadless(messaging: Messaging): Promise<boolean> {
182
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
183
+ return messaging.getIsHeadless.call(messaging, MODULAR_DEPRECATION_ARG);
184
+ }
185
+
186
+ /**
187
+ * On iOS, if your app wants to receive remote messages from FCM (via APNs), you must explicitly register
188
+ * with APNs if auto-registration has been disabled.
189
+ * @param messaging - Messaging instance.
190
+ * @returns Promise that resolves when the device is registered.
191
+ */
192
+ export function registerDeviceForRemoteMessages(messaging: Messaging): Promise<void> {
193
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
194
+ return messaging.registerDeviceForRemoteMessages.call(messaging, MODULAR_DEPRECATION_ARG);
195
+ }
196
+
197
+ /**
198
+ * Returns a boolean value whether the user has registered for remote notifications via
199
+ * `registerDeviceForRemoteMessages()`. For iOS. Android always returns `true`.
200
+ * @param messaging - Messaging instance.
201
+ * @returns Boolean indicating if the device is registered for remote messages.
202
+ */
203
+ export function isDeviceRegisteredForRemoteMessages(messaging: Messaging): boolean {
204
+ return withModularFlag(() => messaging.isDeviceRegisteredForRemoteMessages);
205
+ }
206
+
207
+ /**
208
+ * Unregisters the app from receiving remote notifications.
209
+ * @param messaging - Messaging instance.
210
+ * @returns Promise that resolves when the device is unregistered.
211
+ */
212
+ export function unregisterDeviceForRemoteMessages(messaging: Messaging): Promise<void> {
213
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
214
+ return messaging.unregisterDeviceForRemoteMessages.call(messaging, MODULAR_DEPRECATION_ARG);
215
+ }
216
+
217
+ /**
218
+ * On iOS, it is possible to get the users APNs token. This may be required if you want to send messages to your
219
+ * iOS devices without using the FCM service.
220
+ * @param messaging - Messaging instance.
221
+ * @returns Promise that resolves with the APNs token or null.
222
+ */
223
+ export function getAPNSToken(messaging: Messaging): Promise<string | null> {
224
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
225
+ return messaging.getAPNSToken.call(messaging, MODULAR_DEPRECATION_ARG);
226
+ }
227
+
228
+ /**
229
+ * On iOS, This method is used to set the APNs Token received by the application delegate.
230
+ * Note that the token is expected to be a hexadecimal string, as it is an NSData type in
231
+ * the underlying native firebase SDK, and raw data may only be passed as a string if it is
232
+ * hex encoded. Calling code is responsible for correct encoding, you should verify by comparing
233
+ * the results of `getAPNSToken()` with your token parameter to make sure they are equivalent.
234
+ *
235
+ * Messaging uses method swizzling to ensure that the APNs token is set automatically.
236
+ * However, if you have disabled swizzling by setting FirebaseAppDelegateProxyEnabled to NO
237
+ * in your app's Info.plist, you should manually set the APNs token in your application
238
+ * delegate's application(_:didRegisterForRemoteNotificationsWithDeviceToken:) method.
239
+ *
240
+ * If you would like to set the type of the APNs token, rather than relying on automatic
241
+ * detection, provide a type of either 'prod', 'sandbox'. Omitting the type parameter
242
+ * or specifying 'unknown' will rely on automatic type detection based on provisioning profile.
243
+ *
244
+ * At a native level you may also call objective-c `[FIRMessaging setAPNSToken];` as needed.
245
+ *
246
+ * @param messaging - Messaging instance.
247
+ * @param token - A hexadecimal string representing your APNs token.
248
+ * @param type - Optional. A string specifying 'prod', 'sandbox' or 'unknown' token type.
249
+ * @returns Promise that resolves when the APNs token is set.
250
+ */
251
+ export function setAPNSToken(messaging: Messaging, token: string, type?: string): Promise<void> {
252
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
253
+ return messaging.setAPNSToken.call(messaging, token, type, MODULAR_DEPRECATION_ARG);
254
+ }
255
+
256
+ /**
257
+ * Returns a `AuthorizationStatus` as to whether the user has messaging permission for this app.
258
+ * @param messaging - Messaging instance.
259
+ * @returns Promise that resolves with the authorization status.
260
+ */
261
+ export function hasPermission(messaging: Messaging): Promise<AuthorizationStatus> {
262
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
263
+ return messaging.hasPermission.call(messaging, MODULAR_DEPRECATION_ARG);
264
+ }
265
+
266
+ /**
267
+ * Called when the FCM server deletes pending messages.
268
+ * @param messaging - Messaging instance.
269
+ * @param listener - Called when the FCM deletes pending messages.
270
+ * @returns Function to unsubscribe from the deleted messages listener.
271
+ */
272
+ export function onDeletedMessages(messaging: Messaging, listener: () => void): () => void {
273
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
274
+ return messaging.onDeletedMessages.call(messaging, listener, MODULAR_DEPRECATION_ARG);
275
+ }
276
+
277
+ /**
278
+ * When sending a `RemoteMessage`, this listener is called when the message has been sent to FCM.
279
+ * @param messaging - Messaging instance.
280
+ * @param listener - Called when the FCM sends the remote message to FCM.
281
+ * @returns Function to unsubscribe from the message sent listener.
282
+ */
283
+ export function onMessageSent(
284
+ messaging: Messaging,
285
+ listener: (messageId: string) => any,
286
+ ): () => void {
287
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
288
+ return messaging.onMessageSent.call(messaging, listener, MODULAR_DEPRECATION_ARG);
289
+ }
290
+
291
+ /**
292
+ * When sending a `RemoteMessage`, this listener is called when an error is thrown and the
293
+ * message could not be sent.
294
+ * @param messaging - Messaging instance.
295
+ * @param listener - Called when the FCM sends the remote message to FCM.
296
+ * @returns Function to unsubscribe from the send error listener.
297
+ */
298
+ export function onSendError(
299
+ messaging: Messaging,
300
+ listener: (evt: SendErrorEvent) => any,
301
+ ): () => void {
302
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
303
+ return messaging.onSendError.call(messaging, listener, MODULAR_DEPRECATION_ARG);
304
+ }
305
+
306
+ /**
307
+ * Set a message handler function which is called when the app is in the background
308
+ * or terminated. In Android, a headless task is created, allowing you to access the React Native environment
309
+ * to perform tasks such as updating local storage, or sending a network request.
310
+ * @param messaging - Messaging instance.
311
+ * @param handler - Called when a message is sent and the application is in a background or terminated state.
312
+ * @returns void
313
+ */
314
+ export function setBackgroundMessageHandler(
315
+ messaging: Messaging,
316
+ handler: (message: RemoteMessage) => Promise<any>,
317
+ ): void {
318
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
319
+ return messaging.setBackgroundMessageHandler.call(messaging, handler, MODULAR_DEPRECATION_ARG);
320
+ }
321
+
322
+ /**
323
+ * Set a handler function which is called when the `${App Name} notifications settings`
324
+ * link in iOS settings is clicked.
325
+ * @param messaging - Messaging instance.
326
+ * @param handler - Called when link in iOS settings is clicked.
327
+ * @returns void
328
+ */
329
+ export function setOpenSettingsForNotificationsHandler(
330
+ messaging: Messaging,
331
+ handler: (message: RemoteMessage) => any,
332
+ ): void {
333
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
334
+ return (messaging.setOpenSettingsForNotificationsHandler as any).call(
335
+ messaging,
336
+ handler,
337
+ MODULAR_DEPRECATION_ARG,
338
+ );
339
+ }
340
+
341
+ /**
342
+ * Send a new `RemoteMessage` to the FCM server.
343
+ * @param messaging - Messaging instance.
344
+ * @param message - A `RemoteMessage` interface.
345
+ * @returns Promise that resolves when the message is sent.
346
+ */
347
+ export function sendMessage(messaging: Messaging, message: RemoteMessage): Promise<void> {
348
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
349
+ return messaging.sendMessage.call(messaging, message, MODULAR_DEPRECATION_ARG);
350
+ }
351
+
352
+ /**
353
+ * Apps can subscribe to a topic, which allows the FCM server to send targeted messages to only those
354
+ * devices subscribed to that topic.
355
+ * @param messaging - Messaging instance.
356
+ * @param topic - The topic name.
357
+ * @returns Promise that resolves when the subscription is complete.
358
+ */
359
+ export function subscribeToTopic(messaging: Messaging, topic: string): Promise<void> {
360
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
361
+ return messaging.subscribeToTopic.call(messaging, topic, MODULAR_DEPRECATION_ARG);
362
+ }
363
+
364
+ /**
365
+ * Unsubscribe the device from a topic.
366
+ * @param messaging - Messaging instance.
367
+ * @param topic - The topic name.
368
+ * @returns Promise that resolves when the unsubscription is complete.
369
+ */
370
+ export function unsubscribeFromTopic(messaging: Messaging, topic: string): Promise<void> {
371
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
372
+ return messaging.unsubscribeFromTopic.call(messaging, topic, MODULAR_DEPRECATION_ARG);
373
+ }
374
+
375
+ /**
376
+ * Returns a boolean whether message delivery metrics are exported to BigQuery.
377
+ * @param messaging - Messaging instance.
378
+ * @returns Boolean indicating if message delivery metrics are exported to BigQuery.
379
+ */
380
+ export function isDeliveryMetricsExportToBigQueryEnabled(messaging: Messaging): boolean {
381
+ return withModularFlag(() => messaging.isDeliveryMetricsExportToBigQueryEnabled);
382
+ }
383
+
384
+ /**
385
+ * Returns a boolean whether message delegation is enabled. Android only,
386
+ * always returns false on iOS
387
+ * @param messaging - Messaging instance.
388
+ * @returns Boolean indicating if notification delegation is enabled.
389
+ */
390
+ export function isNotificationDelegationEnabled(messaging: Messaging): boolean {
391
+ return withModularFlag(() => messaging.isNotificationDelegationEnabled);
392
+ }
393
+
394
+ /**
395
+ * Sets whether message notification delegation is enabled or disabled.
396
+ * The value is false by default. Set this to true to allow delegation of notification to Google Play Services.
397
+ * Note if true message handlers will not function on Android, and it has no effect on iOS
398
+ * @param messaging - Messaging instance.
399
+ * @param enabled - A boolean value to enable or disable delegation of messages to Google Play Services.
400
+ * @returns Promise that resolves when the setting is updated.
401
+ */
402
+ export function setNotificationDelegationEnabled(
403
+ messaging: Messaging,
404
+ enabled: boolean,
405
+ ): Promise<void> {
406
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
407
+ return (messaging.setNotificationDelegationEnabled as any).call(
408
+ messaging,
409
+ enabled,
410
+ MODULAR_DEPRECATION_ARG,
411
+ );
412
+ }
413
+
414
+ /**
415
+ * Checks if all required APIs exist in the browser.
416
+ * @param messaging - Messaging instance.
417
+ * @returns Promise that resolves with a boolean indicating if the APIs are supported.
418
+ */
419
+ export function isSupported(messaging: Messaging): Promise<boolean> {
420
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
421
+ return messaging.isSupported.call(messaging, MODULAR_DEPRECATION_ARG);
422
+ }
423
+
424
+ /**
425
+ * Sets whether message delivery metrics are exported to BigQuery is enabled or disabled.
426
+ * The value is false by default. Set this to true to allow exporting of message delivery metrics to BigQuery.
427
+ * @param messaging - Messaging instance.
428
+ * @param enabled - A boolean value to enable or disable exporting of message delivery metrics to BigQuery.
429
+ * @returns Promise that resolves when the setting is updated.
430
+ */
431
+ export function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(
432
+ messaging: Messaging,
433
+ enabled: boolean,
434
+ ): Promise<void> {
435
+ // @ts-ignore - MODULAR_DEPRECATION_ARG is used internally
436
+ return (messaging.setDeliveryMetricsExportToBigQuery as any).call(
437
+ messaging,
438
+ enabled,
439
+ MODULAR_DEPRECATION_ARG,
440
+ );
441
+ }
442
+
443
+ export {
444
+ AuthorizationStatus,
445
+ NotificationAndroidPriority,
446
+ NotificationAndroidVisibility,
447
+ } from './statics';