@react-native-firebase/messaging 20.3.0 → 20.5.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/CHANGELOG.md +11 -0
- package/__tests__/messaging.test.ts +153 -0
- package/android/src/main/java/io/invertase/firebase/messaging/ReactNativeFirebaseMessagingReceiver.java +4 -0
- package/ios/RNFBMessaging/RNFBMessaging+NSNotificationCenter.m +4 -4
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -32
- package/lib/modular/index.d.ts +297 -0
- package/{modular → lib/modular}/index.js +76 -64
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [20.5.0](https://github.com/invertase/react-native-firebase/compare/v20.4.0...v20.5.0) (2024-09-11)
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
- **messaging, android:** handle nullable broadcast intent ([#7893](https://github.com/invertase/react-native-firebase/issues/7893)) ([#7960](https://github.com/invertase/react-native-firebase/issues/7960)) ([c1ac022](https://github.com/invertase/react-native-firebase/commit/c1ac022e4e9d3effb2f0fb3404ad375d9fcbe4b6))
|
11
|
+
- **messaging, ios:** fixed isHeadless for react-native-navigation ([#7868](https://github.com/invertase/react-native-firebase/issues/7868)) ([3875cc6](https://github.com/invertase/react-native-firebase/commit/3875cc6077e5fd6b35e201356aca632e43a2e301))
|
12
|
+
|
13
|
+
## [20.4.0](https://github.com/invertase/react-native-firebase/compare/v20.3.0...v20.4.0) (2024-08-13)
|
14
|
+
|
15
|
+
**Note:** Version bump only for package @react-native-firebase/messaging
|
16
|
+
|
6
17
|
## [20.3.0](https://github.com/invertase/react-native-firebase/compare/v20.2.1...v20.3.0) (2024-07-19)
|
7
18
|
|
8
19
|
**Note:** Version bump only for package @react-native-firebase/messaging
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import { describe, expect, it } from '@jest/globals';
|
2
|
+
|
3
|
+
import {
|
4
|
+
getMessaging,
|
5
|
+
deleteToken,
|
6
|
+
getToken,
|
7
|
+
onMessage,
|
8
|
+
onNotificationOpenedApp,
|
9
|
+
onTokenRefresh,
|
10
|
+
requestPermission,
|
11
|
+
isAutoInitEnabled,
|
12
|
+
setAutoInitEnabled,
|
13
|
+
getInitialNotification,
|
14
|
+
getDidOpenSettingsForNotification,
|
15
|
+
getIsHeadless,
|
16
|
+
registerDeviceForRemoteMessages,
|
17
|
+
isDeviceRegisteredForRemoteMessages,
|
18
|
+
unregisterDeviceForRemoteMessages,
|
19
|
+
getAPNSToken,
|
20
|
+
setAPNSToken,
|
21
|
+
hasPermission,
|
22
|
+
onDeletedMessages,
|
23
|
+
onMessageSent,
|
24
|
+
onSendError,
|
25
|
+
setBackgroundMessageHandler,
|
26
|
+
setOpenSettingsForNotificationsHandler,
|
27
|
+
sendMessage,
|
28
|
+
subscribeToTopic,
|
29
|
+
unsubscribeFromTopic,
|
30
|
+
isDeliveryMetricsExportToBigQueryEnabled,
|
31
|
+
isSupported,
|
32
|
+
experimentalSetDeliveryMetricsExportedToBigQueryEnabled,
|
33
|
+
} from '../lib';
|
34
|
+
|
35
|
+
describe('Firestore', function () {
|
36
|
+
describe('modular', function () {
|
37
|
+
it('`getMessaging` function is properly exposed to end user', function () {
|
38
|
+
expect(getMessaging).toBeDefined();
|
39
|
+
});
|
40
|
+
|
41
|
+
it('`deleteToken` function is properly exposed to end user', function () {
|
42
|
+
expect(deleteToken).toBeDefined();
|
43
|
+
});
|
44
|
+
|
45
|
+
it('`getToken` function is properly exposed to end user', function () {
|
46
|
+
expect(getToken).toBeDefined();
|
47
|
+
});
|
48
|
+
|
49
|
+
it('`onMessage` function is properly exposed to end user', function () {
|
50
|
+
expect(onMessage).toBeDefined();
|
51
|
+
});
|
52
|
+
|
53
|
+
it('`onNotificationOpenedApp` function is properly exposed to end user', function () {
|
54
|
+
expect(onNotificationOpenedApp).toBeDefined();
|
55
|
+
});
|
56
|
+
|
57
|
+
it('`onTokenRefresh` function is properly exposed to end user', function () {
|
58
|
+
expect(onTokenRefresh).toBeDefined();
|
59
|
+
});
|
60
|
+
|
61
|
+
it('`requestPermission` function is properly exposed to end user', function () {
|
62
|
+
expect(requestPermission).toBeDefined();
|
63
|
+
});
|
64
|
+
|
65
|
+
it('`isAutoInitEnabled` function is properly exposed to end user', function () {
|
66
|
+
expect(isAutoInitEnabled).toBeDefined();
|
67
|
+
});
|
68
|
+
|
69
|
+
it('`setAutoInitEnabled` function is properly exposed to end user', function () {
|
70
|
+
expect(setAutoInitEnabled).toBeDefined();
|
71
|
+
});
|
72
|
+
|
73
|
+
it('`getInitialNotification` function is properly exposed to end user', function () {
|
74
|
+
expect(getInitialNotification).toBeDefined();
|
75
|
+
});
|
76
|
+
|
77
|
+
it('`getDidOpenSettingsForNotification` function is properly exposed to end user', function () {
|
78
|
+
expect(getDidOpenSettingsForNotification).toBeDefined();
|
79
|
+
});
|
80
|
+
|
81
|
+
it('`getIsHeadless` function is properly exposed to end user', function () {
|
82
|
+
expect(getIsHeadless).toBeDefined();
|
83
|
+
});
|
84
|
+
|
85
|
+
it('`registerDeviceForRemoteMessages` function is properly exposed to end user', function () {
|
86
|
+
expect(registerDeviceForRemoteMessages).toBeDefined();
|
87
|
+
});
|
88
|
+
|
89
|
+
it('`isDeviceRegisteredForRemoteMessages` function is properly exposed to end user', function () {
|
90
|
+
expect(isDeviceRegisteredForRemoteMessages).toBeDefined();
|
91
|
+
});
|
92
|
+
|
93
|
+
it('`unregisterDeviceForRemoteMessages` function is properly exposed to end user', function () {
|
94
|
+
expect(unregisterDeviceForRemoteMessages).toBeDefined();
|
95
|
+
});
|
96
|
+
|
97
|
+
it('`getAPNSToken` function is properly exposed to end user', function () {
|
98
|
+
expect(getAPNSToken).toBeDefined();
|
99
|
+
});
|
100
|
+
|
101
|
+
it('`setAPNSToken` function is properly exposed to end user', function () {
|
102
|
+
expect(setAPNSToken).toBeDefined();
|
103
|
+
});
|
104
|
+
|
105
|
+
it('`hasPermission` function is properly exposed to end user', function () {
|
106
|
+
expect(hasPermission).toBeDefined();
|
107
|
+
});
|
108
|
+
|
109
|
+
it('`onDeletedMessages` function is properly exposed to end user', function () {
|
110
|
+
expect(onDeletedMessages).toBeDefined();
|
111
|
+
});
|
112
|
+
|
113
|
+
it('`onMessageSent` function is properly exposed to end user', function () {
|
114
|
+
expect(onMessageSent).toBeDefined();
|
115
|
+
});
|
116
|
+
|
117
|
+
it('`onSendError` function is properly exposed to end user', function () {
|
118
|
+
expect(onSendError).toBeDefined();
|
119
|
+
});
|
120
|
+
|
121
|
+
it('`setBackgroundMessageHandler` function is properly exposed to end user', function () {
|
122
|
+
expect(setBackgroundMessageHandler).toBeDefined();
|
123
|
+
});
|
124
|
+
|
125
|
+
it('`setOpenSettingsForNotificationsHandler` function is properly exposed to end user', function () {
|
126
|
+
expect(setOpenSettingsForNotificationsHandler).toBeDefined();
|
127
|
+
});
|
128
|
+
|
129
|
+
it('`sendMessage` function is properly exposed to end user', function () {
|
130
|
+
expect(sendMessage).toBeDefined();
|
131
|
+
});
|
132
|
+
|
133
|
+
it('`subscribeToTopic` function is properly exposed to end user', function () {
|
134
|
+
expect(subscribeToTopic).toBeDefined();
|
135
|
+
});
|
136
|
+
|
137
|
+
it('`unsubscribeFromTopic` function is properly exposed to end user', function () {
|
138
|
+
expect(unsubscribeFromTopic).toBeDefined();
|
139
|
+
});
|
140
|
+
|
141
|
+
it('`isDeliveryMetricsExportToBigQueryEnabled` function is properly exposed to end user', function () {
|
142
|
+
expect(isDeliveryMetricsExportToBigQueryEnabled).toBeDefined();
|
143
|
+
});
|
144
|
+
|
145
|
+
it('`isSupported` function is properly exposed to end user', function () {
|
146
|
+
expect(isSupported).toBeDefined();
|
147
|
+
});
|
148
|
+
|
149
|
+
it('`experimentalSetDeliveryMetricsExportedToBigQueryEnabled` function is properly exposed to end user', function () {
|
150
|
+
expect(experimentalSetDeliveryMetricsExportedToBigQueryEnabled).toBeDefined();
|
151
|
+
});
|
152
|
+
});
|
153
|
+
});
|
@@ -22,6 +22,10 @@ public class ReactNativeFirebaseMessagingReceiver extends BroadcastReceiver {
|
|
22
22
|
if (ReactNativeFirebaseApp.getApplicationContext() == null) {
|
23
23
|
ReactNativeFirebaseApp.setApplicationContext(context.getApplicationContext());
|
24
24
|
}
|
25
|
+
if (intent.getExtras() == null) {
|
26
|
+
Log.e(TAG, "broadcast intent received with no extras");
|
27
|
+
return;
|
28
|
+
}
|
25
29
|
RemoteMessage remoteMessage = new RemoteMessage(intent.getExtras());
|
26
30
|
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
|
27
31
|
|
@@ -96,8 +96,8 @@
|
|
96
96
|
|
97
97
|
if (notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
98
98
|
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
99
|
+
isHeadless = YES;
|
99
100
|
if (rctRootView != nil) {
|
100
|
-
isHeadless = YES;
|
101
101
|
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
102
102
|
? [rctRootView.appProperties mutableCopy]
|
103
103
|
: [NSMutableDictionary dictionary];
|
@@ -120,8 +120,8 @@
|
|
120
120
|
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
121
121
|
// #endif
|
122
122
|
} else {
|
123
|
+
isHeadless = NO;
|
123
124
|
if (rctRootView != nil) {
|
124
|
-
isHeadless = NO;
|
125
125
|
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
126
126
|
? [rctRootView.appProperties mutableCopy]
|
127
127
|
: [NSMutableDictionary dictionary];
|
@@ -133,8 +133,8 @@
|
|
133
133
|
}
|
134
134
|
}
|
135
135
|
} else {
|
136
|
+
isHeadless = NO;
|
136
137
|
if (rctRootView != nil) {
|
137
|
-
isHeadless = NO;
|
138
138
|
NSMutableDictionary *appPropertiesDict = rctRootView.appProperties != nil
|
139
139
|
? [rctRootView.appProperties mutableCopy]
|
140
140
|
: [NSMutableDictionary dictionary];
|
@@ -148,6 +148,7 @@
|
|
148
148
|
}
|
149
149
|
|
150
150
|
- (void)application_onDidEnterForeground {
|
151
|
+
isHeadless = NO;
|
151
152
|
if ([UIApplication sharedApplication].delegate != nil &&
|
152
153
|
[UIApplication sharedApplication].delegate.window != nil &&
|
153
154
|
[UIApplication sharedApplication].delegate.window.rootViewController != nil &&
|
@@ -160,7 +161,6 @@
|
|
160
161
|
if (rctRootView.appProperties != nil &&
|
161
162
|
[rctRootView.appProperties[@"isHeadless"] isEqual:@(YES)]) {
|
162
163
|
NSMutableDictionary *appPropertiesDict = [rctRootView.appProperties mutableCopy];
|
163
|
-
isHeadless = NO;
|
164
164
|
if ([appPropertiesDict objectForKey:@"isHeadless"] != nil &&
|
165
165
|
[appPropertiesDict[@"isHeadless"] isEqual:@([RCTConvert BOOL:@(YES)])]) {
|
166
166
|
appPropertiesDict[@"isHeadless"] = @([RCTConvert BOOL:@(isHeadless)]);
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
@@ -34,38 +34,6 @@ import { AppRegistry, Platform } from 'react-native';
|
|
34
34
|
import remoteMessageOptions from './remoteMessageOptions';
|
35
35
|
import version from './version';
|
36
36
|
|
37
|
-
export {
|
38
|
-
getMessaging,
|
39
|
-
deleteToken,
|
40
|
-
getToken,
|
41
|
-
onMessage,
|
42
|
-
onNotificationOpenedApp,
|
43
|
-
onTokenRefresh,
|
44
|
-
requestPermission,
|
45
|
-
isAutoInitEnabled,
|
46
|
-
setAutoInitEnabled,
|
47
|
-
getInitialNotification,
|
48
|
-
getDidOpenSettingsForNotification,
|
49
|
-
getIsHeadless,
|
50
|
-
registerDeviceForRemoteMessages,
|
51
|
-
isDeviceRegisteredForRemoteMessages,
|
52
|
-
unregisterDeviceForRemoteMessages,
|
53
|
-
getAPNSToken,
|
54
|
-
setAPNSToken,
|
55
|
-
hasPermission,
|
56
|
-
onDeletedMessages,
|
57
|
-
onMessageSent,
|
58
|
-
onSendError,
|
59
|
-
setBackgroundMessageHandler,
|
60
|
-
setOpenSettingsForNotificationsHandler,
|
61
|
-
sendMessage,
|
62
|
-
subscribeToTopic,
|
63
|
-
unsubscribeFromTopic,
|
64
|
-
experimentalSetDeliveryMetricsExportedToBigQueryEnabled,
|
65
|
-
isDeliveryMetricsExportToBigQueryEnabled,
|
66
|
-
isSupported,
|
67
|
-
} from '../modular/index';
|
68
|
-
|
69
37
|
const statics = {
|
70
38
|
AuthorizationStatus: {
|
71
39
|
NOT_DETERMINED: -1,
|
@@ -538,6 +506,8 @@ export default createModuleNamespace({
|
|
538
506
|
ModuleClass: FirebaseMessagingModule,
|
539
507
|
});
|
540
508
|
|
509
|
+
export * from './modular';
|
510
|
+
|
541
511
|
// import messaging, { firebase } from '@react-native-firebase/messaging';
|
542
512
|
// messaging().X(...);
|
543
513
|
// firebase.messaging().X(...);
|
@@ -0,0 +1,297 @@
|
|
1
|
+
import { FirebaseMessagingTypes } from '..';
|
2
|
+
import { FirebaseApp } from '@firebase/app-types';
|
3
|
+
|
4
|
+
import Messaging = FirebaseStorageTypes.Module;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Returns a Messaging instance for the given app.
|
8
|
+
* @param app - The Firebase app instance. Optional.
|
9
|
+
* @returns A Messaging instance.
|
10
|
+
*/
|
11
|
+
export function getMessaging(app?: FirebaseApp): Messaging;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Removes access to an FCM token previously authorized by its scope.
|
15
|
+
* Messages sent by the server to this token will fail.
|
16
|
+
* @param messaging - Messaging instance.
|
17
|
+
* @param tokenOptions - Options to override senderId (iOS) and projectId (Android).
|
18
|
+
* @returns A promise that resolves when the token is deleted.
|
19
|
+
*/
|
20
|
+
export function deleteToken(
|
21
|
+
messaging: Messaging,
|
22
|
+
tokenOptions?: FirebaseMessagingTypes.NativeTokenOptions,
|
23
|
+
): Promise<void>;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Returns an FCM token for this device. Optionally, you can specify custom options for your own use case.
|
27
|
+
* @param messaging - Messaging instance.
|
28
|
+
* @param options - Options to override senderId (iOS) and appName.
|
29
|
+
* @returns A promise that resolves with the FCM token.
|
30
|
+
*/
|
31
|
+
export function getToken(
|
32
|
+
messaging: Messaging,
|
33
|
+
options?: FirebaseMessagingTypes.GetTokenOptions & FirebaseMessagingTypes.NativeTokenOptions,
|
34
|
+
): Promise<string>;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* When any FCM payload is received, the listener callback is called with a `RemoteMessage`.
|
38
|
+
* This subscriber method is only called when the app is active (in the foreground).
|
39
|
+
* @param messaging - Messaging instance.
|
40
|
+
* @param listener - Called with a `RemoteMessage` when a new FCM payload is received from the server.
|
41
|
+
* @returns A function to unsubscribe from the message listener.
|
42
|
+
*/
|
43
|
+
export function onMessage(
|
44
|
+
messaging: Messaging,
|
45
|
+
listener: (message: FirebaseMessagingTypes.RemoteMessage) => any,
|
46
|
+
): () => void;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* When the user presses a notification displayed via FCM, this listener will be called if the app
|
50
|
+
* has opened from a background state.
|
51
|
+
* @param messaging - Messaging instance.
|
52
|
+
* @param listener - Called with a `RemoteMessage` when a notification press opens the application.
|
53
|
+
* @returns A function to unsubscribe from the notification opened listener.
|
54
|
+
*/
|
55
|
+
export function onNotificationOpenedApp(
|
56
|
+
messaging: Messaging,
|
57
|
+
listener: (message: FirebaseMessagingTypes.RemoteMessage) => any,
|
58
|
+
): () => void;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Called when a new registration token is generated for the device. This event can happen when a
|
62
|
+
* token expires or when the server invalidates the token.
|
63
|
+
* This subscriber method is only called when the app is active (in the foreground).
|
64
|
+
* @param messaging - Messaging instance.
|
65
|
+
* @param listener - Called with an FCM token when the token is refreshed.
|
66
|
+
* @returns A function to unsubscribe from the token refresh listener.
|
67
|
+
*/
|
68
|
+
export function onTokenRefresh(messaging: Messaging, listener: (token: string) => any): () => void;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* On iOS, messaging permission must be requested by the current application before messages can
|
72
|
+
* be received or sent.
|
73
|
+
* @param messaging - Messaging instance.
|
74
|
+
* @param iosPermissions - All the available permissions for iOS that can be requested.
|
75
|
+
* @returns A promise that resolves with the authorization status.
|
76
|
+
*/
|
77
|
+
export function requestPermission(
|
78
|
+
messaging: Messaging,
|
79
|
+
iosPermissions?: FirebaseMessagingTypes.IOSPermissions,
|
80
|
+
): Promise<FirebaseMessagingTypes.AuthorizationStatus>;
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Returns whether messaging auto initialization is enabled or disabled for the device.
|
84
|
+
* @param messaging - Messaging instance.
|
85
|
+
* @returns A boolean indicating whether auto initialization is enabled.
|
86
|
+
*/
|
87
|
+
export function isAutoInitEnabled(messaging: Messaging): boolean;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Sets whether messaging auto initialization is enabled or disabled for the device.
|
91
|
+
* @param messaging - Messaging instance.
|
92
|
+
* @param enabled - A boolean value to enable or disable auto initialization.
|
93
|
+
* @returns A promise that resolves when the setting is updated.
|
94
|
+
*/
|
95
|
+
export function setAutoInitEnabled(messaging: Messaging, enabled: boolean): Promise<void>;
|
96
|
+
|
97
|
+
/**
|
98
|
+
* When a notification from FCM has triggered the application to open from a quit state,
|
99
|
+
* this method will return a `RemoteMessage` containing the notification data, or `null` if
|
100
|
+
* the app was opened via another method.
|
101
|
+
* @param messaging - Messaging instance.
|
102
|
+
* @returns A promise that resolves with the initial notification or null.
|
103
|
+
*/
|
104
|
+
export function getInitialNotification(
|
105
|
+
messaging: Messaging,
|
106
|
+
): Promise<FirebaseMessagingTypes.RemoteMessage | null>;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* When the app is opened from iOS notifications settings from a quit state,
|
110
|
+
* this method will return `true` or `false` if the app was opened via another method.
|
111
|
+
* @param messaging - Messaging instance.
|
112
|
+
* @returns A promise that resolves with a boolean indicating if the app was opened from settings.
|
113
|
+
*/
|
114
|
+
export function getDidOpenSettingsForNotification(messaging: Messaging): Promise<boolean>;
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Returns whether the root view is headless or not
|
118
|
+
* i.e. true if the app was launched in the background (for example, by data-only cloud message).
|
119
|
+
* @param messaging - Messaging instance.
|
120
|
+
* @returns A promise that resolves with a boolean indicating if the app is headless.
|
121
|
+
*/
|
122
|
+
export function getIsHeadless(messaging: Messaging): Promise<boolean>;
|
123
|
+
|
124
|
+
/**
|
125
|
+
* On iOS, if your app wants to receive remote messages from FCM (via APNs), you must explicitly register
|
126
|
+
* with APNs if auto-registration has been disabled.
|
127
|
+
* @param messaging - Messaging instance.
|
128
|
+
* @returns A promise that resolves when the device is registered.
|
129
|
+
*/
|
130
|
+
export function registerDeviceForRemoteMessages(messaging: Messaging): Promise<void>;
|
131
|
+
|
132
|
+
/**
|
133
|
+
* Returns a boolean value whether the user has registered for remote notifications via
|
134
|
+
* `registerDeviceForRemoteMessages()`. For iOS. Android always returns `true`.
|
135
|
+
* @param messaging - Messaging instance.
|
136
|
+
* @returns A boolean indicating if the device is registered for remote messages.
|
137
|
+
*/
|
138
|
+
export function isDeviceRegisteredForRemoteMessages(messaging: Messaging): boolean;
|
139
|
+
|
140
|
+
/**
|
141
|
+
* Unregisters the app from receiving remote notifications.
|
142
|
+
* @param messaging - Messaging instance.
|
143
|
+
* @returns A promise that resolves when the device is unregistered.
|
144
|
+
*/
|
145
|
+
export function unregisterDeviceForRemoteMessages(messaging: Messaging): Promise<void>;
|
146
|
+
|
147
|
+
/**
|
148
|
+
* On iOS, it is possible to get the users APNs token. This may be required if you want to send messages to your
|
149
|
+
* iOS devices without using the FCM service.
|
150
|
+
* @param messaging - Messaging instance.
|
151
|
+
* @returns A promise that resolves with the APNs token or null.
|
152
|
+
*/
|
153
|
+
export function getAPNSToken(messaging: Messaging): Promise<string | null>;
|
154
|
+
|
155
|
+
/**
|
156
|
+
* On iOS, This method is used to set the APNs Token received by the application delegate.
|
157
|
+
* Note that the token is expected to be a hexadecimal string, as it is an NSData type in
|
158
|
+
* the underlying native firebase SDK, and raw data may only be passed as a string if it is
|
159
|
+
* hex encoded. Calling code is responsible for correct encoding, you should verify by comparing
|
160
|
+
* the results of `getAPNSToken()` with your token parameter to make sure they are equivalent.
|
161
|
+
*
|
162
|
+
* Messaging uses method swizzling to ensure that the APNs token is set automatically.
|
163
|
+
* However, if you have disabled swizzling by setting FirebaseAppDelegateProxyEnabled to NO
|
164
|
+
* in your app’s Info.plist, you should manually set the APNs token in your application
|
165
|
+
* delegate’s application(_:didRegisterForRemoteNotificationsWithDeviceToken:) method.
|
166
|
+
*
|
167
|
+
* If you would like to set the type of the APNs token, rather than relying on automatic
|
168
|
+
* detection, provide a type of either 'prod', 'sandbox'. Omitting the type parameter
|
169
|
+
* or specifying 'unknown' will rely on automatic type detection based on provisioning profile.
|
170
|
+
*
|
171
|
+
* At a native level you may also call objective-c `[FIRMessaging setAPNSToken];` as needed.
|
172
|
+
*
|
173
|
+
* @param messaging - Messaging instance.
|
174
|
+
* @param token - A hexadecimal string representing your APNs token.
|
175
|
+
* @param type - Optional. A string specifying 'prod', 'sandbox' or 'unknown' token type.
|
176
|
+
* @returns A promise that resolves when the APNs token is set.
|
177
|
+
*/
|
178
|
+
export function setAPNSToken(messaging: Messaging, token: string, type?: string): Promise<void>;
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Returns a `AuthorizationStatus` as to whether the user has messaging permission for this app.
|
182
|
+
* @param messaging - Messaging instance.
|
183
|
+
* @returns A promise that resolves with the authorization status.
|
184
|
+
*/
|
185
|
+
export function hasPermission(
|
186
|
+
messaging: Messaging,
|
187
|
+
): Promise<FirebaseMessagingTypes.AuthorizationStatus>;
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Called when the FCM server deletes pending messages.
|
191
|
+
* @param messaging - Messaging instance.
|
192
|
+
* @param listener - Called when the FCM deletes pending messages.
|
193
|
+
* @returns A function to unsubscribe from the deleted messages listener.
|
194
|
+
*/
|
195
|
+
export function onDeletedMessages(messaging: Messaging, listener: () => void): () => void;
|
196
|
+
|
197
|
+
/**
|
198
|
+
* When sending a `RemoteMessage`, this listener is called when the message has been sent to FCM.
|
199
|
+
* @param messaging - Messaging instance.
|
200
|
+
* @param listener - Called when the FCM sends the remote message to FCM.
|
201
|
+
* @returns A function to unsubscribe from the message sent listener.
|
202
|
+
*/
|
203
|
+
export function onMessageSent(
|
204
|
+
messaging: Messaging,
|
205
|
+
listener: (messageId: string) => any,
|
206
|
+
): () => void;
|
207
|
+
|
208
|
+
/**
|
209
|
+
* When sending a `RemoteMessage`, this listener is called when an error is thrown and the
|
210
|
+
* message could not be sent.
|
211
|
+
* @param messaging - Messaging instance.
|
212
|
+
* @param listener - Called when the FCM sends the remote message to FCM.
|
213
|
+
* @returns A function to unsubscribe from the send error listener.
|
214
|
+
*/
|
215
|
+
export function onSendError(
|
216
|
+
messaging: Messaging,
|
217
|
+
listener: (evt: FirebaseMessagingTypes.SendErrorEvent) => any,
|
218
|
+
): () => void;
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Set a message handler function which is called when the app is in the background
|
222
|
+
* or terminated. In Android, a headless task is created, allowing you to access the React Native environment
|
223
|
+
* to perform tasks such as updating local storage, or sending a network request.
|
224
|
+
* @param messaging - Messaging instance.
|
225
|
+
* @param handler - Called when a message is sent and the application is in a background or terminated state.
|
226
|
+
* @returns {void}
|
227
|
+
*/
|
228
|
+
export function setBackgroundMessageHandler(
|
229
|
+
messaging: Messaging,
|
230
|
+
handler: (message: FirebaseMessagingTypes.RemoteMessage) => Promise<any>,
|
231
|
+
): void;
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Set a handler function which is called when the `${App Name} notifications settings`
|
235
|
+
* link in iOS settings is clicked.
|
236
|
+
* @param messaging - Messaging instance.
|
237
|
+
* @param handler - Called when link in iOS settings is clicked.
|
238
|
+
* @returns {void}
|
239
|
+
*/
|
240
|
+
export function setOpenSettingsForNotificationsHandler(
|
241
|
+
messaging: Messaging,
|
242
|
+
handler: (message: FirebaseMessagingTypes.RemoteMessage) => any,
|
243
|
+
): void;
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Send a new `RemoteMessage` to the FCM server.
|
247
|
+
* @param messaging - Messaging instance.
|
248
|
+
* @param message - A `RemoteMessage` interface.
|
249
|
+
* @returns A promise that resolves when the message is sent.
|
250
|
+
*/
|
251
|
+
export function sendMessage(
|
252
|
+
messaging: Messaging,
|
253
|
+
message: FirebaseMessagingTypes.RemoteMessage,
|
254
|
+
): Promise<void>;
|
255
|
+
|
256
|
+
/**
|
257
|
+
* Apps can subscribe to a topic, which allows the FCM server to send targeted messages to only those
|
258
|
+
* devices subscribed to that topic.
|
259
|
+
* @param messaging - Messaging instance.
|
260
|
+
* @param topic - The topic name.
|
261
|
+
* @returns A promise that resolves when the subscription is complete.
|
262
|
+
*/
|
263
|
+
export function subscribeToTopic(messaging: Messaging, topic: string): Promise<void>;
|
264
|
+
|
265
|
+
/**
|
266
|
+
* Unsubscribe the device from a topic.
|
267
|
+
* @param messaging - Messaging instance.
|
268
|
+
* @param topic - The topic name.
|
269
|
+
* @returns A promise that resolves when the unsubscription is complete.
|
270
|
+
*/
|
271
|
+
export function unsubscribeFromTopic(messaging: Messaging, topic: string): Promise<void>;
|
272
|
+
|
273
|
+
/**
|
274
|
+
* Returns a boolean whether message delivery metrics are exported to BigQuery.
|
275
|
+
* @param messaging - Messaging instance.
|
276
|
+
* @returns A boolean indicating if message delivery metrics are exported to BigQuery.
|
277
|
+
*/
|
278
|
+
export function isDeliveryMetricsExportToBigQueryEnabled(messaging: Messaging): boolean;
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Checks if all required APIs exist in the browser.
|
282
|
+
* @param messaging - Messaging instance.
|
283
|
+
* @returns A boolean indicating if the APIs are supported.
|
284
|
+
*/
|
285
|
+
export function isSupported(messaging: Messaging): boolean;
|
286
|
+
|
287
|
+
/**
|
288
|
+
* Sets whether message delivery metrics are exported to BigQuery is enabled or disabled.
|
289
|
+
* The value is false by default. Set this to true to allow exporting of message delivery metrics to BigQuery.
|
290
|
+
* @param messaging - Messaging instance.
|
291
|
+
* @param enabled - A boolean value to enable or disable exporting of message delivery metrics to BigQuery.
|
292
|
+
* @returns A promise that resolves when the setting is updated.
|
293
|
+
*/
|
294
|
+
export function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(
|
295
|
+
messaging: Messaging,
|
296
|
+
enabled: boolean,
|
297
|
+
): Promise<void>;
|
@@ -1,8 +1,20 @@
|
|
1
1
|
import { firebase } from '..';
|
2
2
|
|
3
|
+
/**
|
4
|
+
* @typedef {import('..').FirebaseMessagingTypes} FirebaseMessagingTypes
|
5
|
+
* @typedef {import('..').FirebaseMessagingTypes.Module} Messaging
|
6
|
+
* @typedef {import('..').FirebaseMessagingTypes.RemoteMessage} RemoteMessage
|
7
|
+
* @typedef {import('..').FirebaseMessagingTypes.NativeTokenOptions} NativeTokenOptions
|
8
|
+
* @typedef {import('..').FirebaseMessagingTypes.GetTokenOptions} GetTokenOptions
|
9
|
+
* @typedef {import('..').FirebaseMessagingTypes.IOSPermissions} IOSPermissions
|
10
|
+
* @typedef {import('..').FirebaseMessagingTypes.AuthorizationStatus} AuthorizationStatus
|
11
|
+
* @typedef {import('..').FirebaseMessagingTypes.SendErrorEvent} SendErrorEvent
|
12
|
+
* @typedef {import('@firebase/app').FirebaseApp} FirebaseApp
|
13
|
+
*/
|
14
|
+
|
3
15
|
/**
|
4
16
|
* Returns a Messaging instance for the given app.
|
5
|
-
* @param app - FirebaseApp. Optional.
|
17
|
+
* @param {FirebaseApp} [app] - FirebaseApp. Optional.
|
6
18
|
* @returns {Messaging}
|
7
19
|
*/
|
8
20
|
export function getMessaging(app) {
|
@@ -14,10 +26,10 @@ export function getMessaging(app) {
|
|
14
26
|
}
|
15
27
|
|
16
28
|
/**
|
17
|
-
* Removes access to an FCM token previously authorized by
|
29
|
+
* Removes access to an FCM token previously authorized by its scope.
|
18
30
|
* Messages sent by the server to this token will fail.
|
19
|
-
* @param messaging Messaging instance.
|
20
|
-
* @param tokenOptions Options to override senderId (iOS) and projectId (Android).
|
31
|
+
* @param {Messaging} messaging - Messaging instance.
|
32
|
+
* @param {NativeTokenOptions} [tokenOptions] - Options to override senderId (iOS) and projectId (Android).
|
21
33
|
* @returns {Promise<void>}
|
22
34
|
*/
|
23
35
|
export function deleteToken(messaging, tokenOptions) {
|
@@ -29,9 +41,9 @@ export function deleteToken(messaging, tokenOptions) {
|
|
29
41
|
}
|
30
42
|
|
31
43
|
/**
|
32
|
-
* Returns an FCM token for this device. Optionally you can specify
|
33
|
-
* @param messaging Messaging instance.
|
34
|
-
* @param options Options to override senderId (iOS) and appName
|
44
|
+
* Returns an FCM token for this device. Optionally, you can specify custom options for your own use case.
|
45
|
+
* @param {Messaging} messaging - Messaging instance.
|
46
|
+
* @param {GetTokenOptions & NativeTokenOptions} [options] - Options to override senderId (iOS) and appName.
|
35
47
|
* @returns {Promise<string>}
|
36
48
|
*/
|
37
49
|
export function getToken(messaging, options) {
|
@@ -45,20 +57,20 @@ export function getToken(messaging, options) {
|
|
45
57
|
/**
|
46
58
|
* When any FCM payload is received, the listener callback is called with a `RemoteMessage`.
|
47
59
|
* > This subscriber method is only called when the app is active (in the foreground).
|
48
|
-
* @param messaging Messaging instance.
|
49
|
-
* @param listener Called with a `RemoteMessage` when a new FCM payload is received from the server.
|
50
|
-
* @returns {
|
60
|
+
* @param {Messaging} messaging - Messaging instance.
|
61
|
+
* @param {(message: RemoteMessage) => any} listener - Called with a `RemoteMessage` when a new FCM payload is received from the server.
|
62
|
+
* @returns {() => void}
|
51
63
|
*/
|
52
|
-
export function onMessage(messaging,
|
53
|
-
return messaging.onMessage(
|
64
|
+
export function onMessage(messaging, listener) {
|
65
|
+
return messaging.onMessage(listener);
|
54
66
|
}
|
55
67
|
|
56
68
|
/**
|
57
69
|
* When the user presses a notification displayed via FCM, this listener will be called if the app
|
58
70
|
* has opened from a background state.
|
59
|
-
* @param messaging Messaging instance.
|
60
|
-
* @param listener Called with a `RemoteMessage` when a notification press opens the application.
|
61
|
-
* @returns {
|
71
|
+
* @param {Messaging} messaging - Messaging instance.
|
72
|
+
* @param {(message: RemoteMessage) => any} listener - Called with a `RemoteMessage` when a notification press opens the application.
|
73
|
+
* @returns {() => void}
|
62
74
|
*/
|
63
75
|
export function onNotificationOpenedApp(messaging, listener) {
|
64
76
|
return messaging.onNotificationOpenedApp(listener);
|
@@ -68,9 +80,9 @@ export function onNotificationOpenedApp(messaging, listener) {
|
|
68
80
|
* Called when a new registration token is generated for the device. For example, this event can happen when a
|
69
81
|
* token expires or when the server invalidates the token.
|
70
82
|
* > This subscriber method is only called when the app is active (in the foreground).
|
71
|
-
* @param messaging Messaging instance.
|
72
|
-
* @param listener Called with a FCM token when the token is refreshed.
|
73
|
-
* @returns {
|
83
|
+
* @param {Messaging} messaging - Messaging instance.
|
84
|
+
* @param {(token: string) => any} listener - Called with a FCM token when the token is refreshed.
|
85
|
+
* @returns {() => void}
|
74
86
|
*/
|
75
87
|
export function onTokenRefresh(messaging, listener) {
|
76
88
|
return messaging.onTokenRefresh(listener);
|
@@ -79,8 +91,8 @@ export function onTokenRefresh(messaging, listener) {
|
|
79
91
|
/**
|
80
92
|
* On iOS, messaging permission must be requested by the current application before messages can
|
81
93
|
* be received or sent.
|
82
|
-
* @param messaging Messaging instance.
|
83
|
-
* @param iosPermissions All the available permissions for iOS that can be requested
|
94
|
+
* @param {Messaging} messaging - Messaging instance.
|
95
|
+
* @param {IOSPermissions} [iosPermissions] - All the available permissions for iOS that can be requested.
|
84
96
|
* @returns {Promise<AuthorizationStatus>}
|
85
97
|
*/
|
86
98
|
export function requestPermission(messaging, iosPermissions) {
|
@@ -89,7 +101,7 @@ export function requestPermission(messaging, iosPermissions) {
|
|
89
101
|
|
90
102
|
/**
|
91
103
|
* Returns whether messaging auto initialization is enabled or disabled for the device.
|
92
|
-
* @param messaging Messaging instance.
|
104
|
+
* @param {Messaging} messaging - Messaging instance.
|
93
105
|
* @returns {boolean}
|
94
106
|
*/
|
95
107
|
export function isAutoInitEnabled(messaging) {
|
@@ -97,10 +109,10 @@ export function isAutoInitEnabled(messaging) {
|
|
97
109
|
}
|
98
110
|
|
99
111
|
/**
|
100
|
-
*
|
101
|
-
* @param messaging Messaging instance.
|
102
|
-
* @param enabled A boolean value to enable or disable auto initialization.
|
103
|
-
* @returns {Promise<
|
112
|
+
* Sets whether messaging auto initialization is enabled or disabled for the device.
|
113
|
+
* @param {Messaging} messaging - Messaging instance.
|
114
|
+
* @param {boolean} enabled - A boolean value to enable or disable auto initialization.
|
115
|
+
* @returns {Promise<void>}
|
104
116
|
*/
|
105
117
|
export function setAutoInitEnabled(messaging, enabled) {
|
106
118
|
return messaging.setAutoInitEnabled(enabled);
|
@@ -110,7 +122,7 @@ export function setAutoInitEnabled(messaging, enabled) {
|
|
110
122
|
* When a notification from FCM has triggered the application to open from a quit state,
|
111
123
|
* this method will return a `RemoteMessage` containing the notification data, or `null` if
|
112
124
|
* the app was opened via another method.
|
113
|
-
* @param messaging Messaging instance.
|
125
|
+
* @param {Messaging} messaging - Messaging instance.
|
114
126
|
* @returns {Promise<RemoteMessage | null>}
|
115
127
|
*/
|
116
128
|
export function getInitialNotification(messaging) {
|
@@ -120,7 +132,7 @@ export function getInitialNotification(messaging) {
|
|
120
132
|
/**
|
121
133
|
* When the app is opened from iOS notifications settings from a quit state,
|
122
134
|
* this method will return `true` or `false` if the app was opened via another method.
|
123
|
-
* @param messaging Messaging instance.
|
135
|
+
* @param {Messaging} messaging - Messaging instance.
|
124
136
|
* @returns {Promise<boolean>}
|
125
137
|
*/
|
126
138
|
export function getDidOpenSettingsForNotification(messaging) {
|
@@ -130,7 +142,7 @@ export function getDidOpenSettingsForNotification(messaging) {
|
|
130
142
|
/**
|
131
143
|
* Returns whether the root view is headless or not
|
132
144
|
* i.e true if the app was launched in the background (for example, by data-only cloud message)
|
133
|
-
* @param messaging Messaging instance.
|
145
|
+
* @param {Messaging} messaging - Messaging instance.
|
134
146
|
* @returns {Promise<boolean>}
|
135
147
|
*/
|
136
148
|
export function getIsHeadless(messaging) {
|
@@ -140,7 +152,7 @@ export function getIsHeadless(messaging) {
|
|
140
152
|
/**
|
141
153
|
* On iOS, if your app wants to receive remote messages from FCM (via APNs), you must explicitly register
|
142
154
|
* with APNs if auto-registration has been disabled.
|
143
|
-
* @param messaging Messaging instance.
|
155
|
+
* @param {Messaging} messaging - Messaging instance.
|
144
156
|
* @returns {Promise<void>}
|
145
157
|
*/
|
146
158
|
export function registerDeviceForRemoteMessages(messaging) {
|
@@ -149,8 +161,8 @@ export function registerDeviceForRemoteMessages(messaging) {
|
|
149
161
|
|
150
162
|
/**
|
151
163
|
* Returns a boolean value whether the user has registered for remote notifications via
|
152
|
-
* `registerDeviceForRemoteMessages()`. For iOS. Android always returns `true
|
153
|
-
* @param messaging Messaging instance.
|
164
|
+
* `registerDeviceForRemoteMessages()`. For iOS. Android always returns `true`.
|
165
|
+
* @param {Messaging} messaging - Messaging instance.
|
154
166
|
* @returns {boolean}
|
155
167
|
*/
|
156
168
|
export function isDeviceRegisteredForRemoteMessages(messaging) {
|
@@ -159,7 +171,7 @@ export function isDeviceRegisteredForRemoteMessages(messaging) {
|
|
159
171
|
|
160
172
|
/**
|
161
173
|
* Unregisters the app from receiving remote notifications.
|
162
|
-
* @param messaging Messaging instance.
|
174
|
+
* @param {Messaging} messaging - Messaging instance.
|
163
175
|
* @returns {Promise<void>}
|
164
176
|
*/
|
165
177
|
export function unregisterDeviceForRemoteMessages(messaging) {
|
@@ -169,7 +181,7 @@ export function unregisterDeviceForRemoteMessages(messaging) {
|
|
169
181
|
/**
|
170
182
|
* On iOS, it is possible to get the users APNs token. This may be required if you want to send messages to your
|
171
183
|
* iOS devices without using the FCM service.
|
172
|
-
* @param messaging Messaging instance.
|
184
|
+
* @param {Messaging} messaging - Messaging instance.
|
173
185
|
* @returns {Promise<string | null>}
|
174
186
|
*/
|
175
187
|
export function getAPNSToken(messaging) {
|
@@ -181,7 +193,7 @@ export function getAPNSToken(messaging) {
|
|
181
193
|
* Note that the token is expected to be a hexadecimal string, as it is an NSData type in
|
182
194
|
* the underlying native firebase SDK, and raw data may only be passed as a string if it is
|
183
195
|
* hex encoded. Calling code is responsible for correct encoding, you should verify by comparing
|
184
|
-
* the results of `getAPNSToken()` with your token parameter to make sure they are equivalent
|
196
|
+
* the results of `getAPNSToken()` with your token parameter to make sure they are equivalent.
|
185
197
|
*
|
186
198
|
* Messaging uses method swizzling to ensure that the APNs token is set automatically.
|
187
199
|
* However, if you have disabled swizzling by setting FirebaseAppDelegateProxyEnabled to NO
|
@@ -192,11 +204,11 @@ export function getAPNSToken(messaging) {
|
|
192
204
|
* detection, provide a type of either 'prod', 'sandbox'. Omitting the type parameter
|
193
205
|
* or specifying 'unknown' will rely on automatic type detection based on provisioning profile.
|
194
206
|
*
|
195
|
-
* At a native level you may also call objective-c `[FIRMessaging setAPNSToken];` as needed
|
207
|
+
* At a native level you may also call objective-c `[FIRMessaging setAPNSToken];` as needed.
|
196
208
|
*
|
197
|
-
* @param messaging Messaging instance.
|
198
|
-
* @param {string} token
|
199
|
-
* @param {string
|
209
|
+
* @param {Messaging} messaging - Messaging instance.
|
210
|
+
* @param {string} token - A hexadecimal string representing your APNs token.
|
211
|
+
* @param {string} [type] - Optional. A string specifying 'prod', 'sandbox' or 'unknown' token type.
|
200
212
|
* @returns {Promise<void>}
|
201
213
|
*/
|
202
214
|
export function setAPNSToken(messaging, token, type) {
|
@@ -205,7 +217,7 @@ export function setAPNSToken(messaging, token, type) {
|
|
205
217
|
|
206
218
|
/**
|
207
219
|
* Returns a `AuthorizationStatus` as to whether the user has messaging permission for this app.
|
208
|
-
* @param messaging Messaging instance.
|
220
|
+
* @param {Messaging} messaging - Messaging instance.
|
209
221
|
* @returns {Promise<AuthorizationStatus>}
|
210
222
|
*/
|
211
223
|
export function hasPermission(messaging) {
|
@@ -214,9 +226,9 @@ export function hasPermission(messaging) {
|
|
214
226
|
|
215
227
|
/**
|
216
228
|
* Called when the FCM server deletes pending messages.
|
217
|
-
* @param messaging Messaging instance.
|
218
|
-
* @param listener Called when the FCM deletes pending messages.
|
219
|
-
* @returns {
|
229
|
+
* @param {Messaging} messaging - Messaging instance.
|
230
|
+
* @param {() => void} listener - Called when the FCM deletes pending messages.
|
231
|
+
* @returns {() => void}
|
220
232
|
*/
|
221
233
|
export function onDeletedMessages(messaging, listener) {
|
222
234
|
return messaging.onDeletedMessages(listener);
|
@@ -224,9 +236,9 @@ export function onDeletedMessages(messaging, listener) {
|
|
224
236
|
|
225
237
|
/**
|
226
238
|
* When sending a `RemoteMessage`, this listener is called when the message has been sent to FCM.
|
227
|
-
* @param messaging Messaging instance.
|
228
|
-
* @param listener Called when the FCM sends the remote message to FCM.
|
229
|
-
* @returns {
|
239
|
+
* @param {Messaging} messaging - Messaging instance.
|
240
|
+
* @param {(messageId: string) => any} listener - Called when the FCM sends the remote message to FCM.
|
241
|
+
* @returns {() => void}
|
230
242
|
*/
|
231
243
|
export function onMessageSent(messaging, listener) {
|
232
244
|
return messaging.onMessageSent(listener);
|
@@ -234,9 +246,9 @@ export function onMessageSent(messaging, listener) {
|
|
234
246
|
|
235
247
|
/**
|
236
248
|
* When sending a `RemoteMessage`, this listener is called when the message has been sent to FCM.
|
237
|
-
* @param messaging Messaging instance.
|
238
|
-
* @param listener Called when the FCM sends the remote message to FCM.
|
239
|
-
* @returns {
|
249
|
+
* @param {Messaging} messaging - Messaging instance.
|
250
|
+
* @param {(evt: SendErrorEvent) => any} listener - Called when the FCM sends the remote message to FCM.
|
251
|
+
* @returns {() => void}
|
240
252
|
*/
|
241
253
|
export function onSendError(messaging, listener) {
|
242
254
|
return messaging.onSendError(listener);
|
@@ -246,8 +258,8 @@ export function onSendError(messaging, listener) {
|
|
246
258
|
* Set a message handler function which is called when the app is in the background
|
247
259
|
* or terminated. In Android, a headless task is created, allowing you to access the React Native environment
|
248
260
|
* to perform tasks such as updating local storage, or sending a network request.
|
249
|
-
* @param messaging Messaging instance.
|
250
|
-
* @param handler Called when a message is sent and the application is in a background or terminated state.
|
261
|
+
* @param {Messaging} messaging - Messaging instance.
|
262
|
+
* @param {(message: RemoteMessage) => Promise<any>} handler - Called when a message is sent and the application is in a background or terminated state.
|
251
263
|
* @returns {void}
|
252
264
|
*/
|
253
265
|
export function setBackgroundMessageHandler(messaging, handler) {
|
@@ -257,8 +269,8 @@ export function setBackgroundMessageHandler(messaging, handler) {
|
|
257
269
|
/**
|
258
270
|
* Set a handler function which is called when the `${App Name} notifications settings`
|
259
271
|
* link in iOS settings is clicked.
|
260
|
-
* @param messaging Messaging instance.
|
261
|
-
* @param handler Called when link in iOS settings is clicked
|
272
|
+
* @param {Messaging} messaging - Messaging instance.
|
273
|
+
* @param {(message: RemoteMessage) => any} handler - Called when link in iOS settings is clicked.
|
262
274
|
* @returns {void}
|
263
275
|
*/
|
264
276
|
export function setOpenSettingsForNotificationsHandler(messaging, handler) {
|
@@ -267,8 +279,8 @@ export function setOpenSettingsForNotificationsHandler(messaging, handler) {
|
|
267
279
|
|
268
280
|
/**
|
269
281
|
* Send a new `RemoteMessage` to the FCM server.
|
270
|
-
* @param messaging Messaging instance.
|
271
|
-
* @param message A `RemoteMessage` interface.
|
282
|
+
* @param {Messaging} messaging - Messaging instance.
|
283
|
+
* @param {RemoteMessage} message - A `RemoteMessage` interface.
|
272
284
|
* @returns {Promise<void>}
|
273
285
|
*/
|
274
286
|
export function sendMessage(messaging, message) {
|
@@ -278,8 +290,8 @@ export function sendMessage(messaging, message) {
|
|
278
290
|
/**
|
279
291
|
* Apps can subscribe to a topic, which allows the FCM server to send targeted messages to only those
|
280
292
|
* devices subscribed to that topic.
|
281
|
-
* @param messaging Messaging instance.
|
282
|
-
* @param topic The topic name.
|
293
|
+
* @param {Messaging} messaging - Messaging instance.
|
294
|
+
* @param {string} topic - The topic name.
|
283
295
|
* @returns {Promise<void>}
|
284
296
|
*/
|
285
297
|
export function subscribeToTopic(messaging, topic) {
|
@@ -288,8 +300,8 @@ export function subscribeToTopic(messaging, topic) {
|
|
288
300
|
|
289
301
|
/**
|
290
302
|
* Unsubscribe the device from a topic.
|
291
|
-
* @param messaging Messaging instance.
|
292
|
-
* @param topic The topic name.
|
303
|
+
* @param {Messaging} messaging - Messaging instance.
|
304
|
+
* @param {string} topic - The topic name.
|
293
305
|
* @returns {Promise<void>}
|
294
306
|
*/
|
295
307
|
export function unsubscribeFromTopic(messaging, topic) {
|
@@ -298,7 +310,7 @@ export function unsubscribeFromTopic(messaging, topic) {
|
|
298
310
|
|
299
311
|
/**
|
300
312
|
* Returns a boolean whether message delivery metrics are exported to BigQuery.
|
301
|
-
* @param messaging Messaging instance.
|
313
|
+
* @param {Messaging} messaging - Messaging instance.
|
302
314
|
* @returns {boolean}
|
303
315
|
*/
|
304
316
|
export function isDeliveryMetricsExportToBigQueryEnabled(messaging) {
|
@@ -307,7 +319,7 @@ export function isDeliveryMetricsExportToBigQueryEnabled(messaging) {
|
|
307
319
|
|
308
320
|
/**
|
309
321
|
* Checks if all required APIs exist in the browser.
|
310
|
-
* @param messaging Messaging instance.
|
322
|
+
* @param {Messaging} messaging - Messaging instance.
|
311
323
|
* @returns {boolean}
|
312
324
|
*/
|
313
325
|
export function isSupported(messaging) {
|
@@ -317,10 +329,10 @@ export function isSupported(messaging) {
|
|
317
329
|
/**
|
318
330
|
* Sets whether message delivery metrics are exported to BigQuery is enabled or disabled.
|
319
331
|
* The value is false by default. Set this to true to allow exporting of message delivery metrics to BigQuery.
|
320
|
-
* @param messaging Messaging instance.
|
321
|
-
* @param enabled A boolean value to enable or disable exporting of message delivery metrics to BigQuery.
|
332
|
+
* @param {Messaging} messaging - Messaging instance.
|
333
|
+
* @param {boolean} enabled - A boolean value to enable or disable exporting of message delivery metrics to BigQuery.
|
322
334
|
* @returns {Promise<void>}
|
323
335
|
*/
|
324
|
-
export function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging,
|
325
|
-
return messaging.setDeliveryMetricsExportToBigQuery(
|
336
|
+
export function experimentalSetDeliveryMetricsExportedToBigQueryEnabled(messaging, enabled) {
|
337
|
+
return messaging.setDeliveryMetricsExportToBigQuery(enabled);
|
326
338
|
}
|
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// Generated by genversion.
|
2
|
-
module.exports = '20.
|
2
|
+
module.exports = '20.5.0';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/messaging",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.5.0",
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
5
5
|
"description": "React Native Firebase - React Native Firebase provides native integration of Firebase Cloud Messaging (FCM) for both Android & iOS. FCM is a cost free service, allowing for server-device and device-device communication. The React Native Firebase Messaging module provides a simple JavaScript API to interact with FCM.",
|
6
6
|
"main": "lib/index.js",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"messaging"
|
25
25
|
],
|
26
26
|
"peerDependencies": {
|
27
|
-
"@react-native-firebase/app": "20.
|
27
|
+
"@react-native-firebase/app": "20.5.0",
|
28
28
|
"expo": ">=47.0.0"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
@@ -38,5 +38,5 @@
|
|
38
38
|
"publishConfig": {
|
39
39
|
"access": "public"
|
40
40
|
},
|
41
|
-
"gitHead": "
|
41
|
+
"gitHead": "daf2bc9086c14bbb0e1b02a4d4274b7060263eb1"
|
42
42
|
}
|