Add logs when notification device tokens is registered or fails to do so (#8282)
This commit is contained in:
parent
c1b66b364b
commit
1beb9a99c2
1 changed files with 14 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
Notifications,
|
||||
type NotificationTextInput,
|
||||
type Registered,
|
||||
type RegistrationError,
|
||||
} from 'react-native-notifications';
|
||||
import {requestNotifications} from 'react-native-permissions';
|
||||
|
||||
|
|
@ -45,6 +46,8 @@ class PushNotifications {
|
|||
Notifications.events().registerRemoteNotificationsRegistered(this.onRemoteNotificationsRegistered),
|
||||
Notifications.events().registerNotificationReceivedBackground(this.onNotificationReceivedBackground),
|
||||
Notifications.events().registerNotificationReceivedForeground(this.onNotificationReceivedForeground),
|
||||
Notifications.events().registerRemoteNotificationsRegistrationFailed(this.NotificationsRegistrationFailed),
|
||||
Notifications.events().registerRemoteNotificationsRegistrationDenied(this.onRemoteNotificationsRegistrationDenied),
|
||||
];
|
||||
|
||||
if (register) {
|
||||
|
|
@ -276,7 +279,9 @@ class PushNotifications {
|
|||
prefix = Device.PUSH_NOTIFY_ANDROID_REACT_NATIVE;
|
||||
}
|
||||
|
||||
storeDeviceToken(`${prefix}-v2:${deviceToken}`);
|
||||
const token = `${prefix}-v2:${deviceToken}`;
|
||||
storeDeviceToken(token);
|
||||
logDebug('Notification token registered', token);
|
||||
|
||||
// Store the device token in the default database
|
||||
this.requestNotificationReplyPermissions();
|
||||
|
|
@ -284,6 +289,14 @@ class PushNotifications {
|
|||
return null;
|
||||
};
|
||||
|
||||
onRemoteNotificationsRegistrationDenied = () => {
|
||||
logDebug('Notification registration denied');
|
||||
};
|
||||
|
||||
NotificationsRegistrationFailed = (event: RegistrationError) => {
|
||||
logDebug('Notification registration failed', event);
|
||||
};
|
||||
|
||||
removeChannelNotifications = async (serverUrl: string, channelId: string) => {
|
||||
RNUtils.removeChannelNotifications(serverUrl, channelId);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue