Closed
Description
Hi,
I am wondering if I am missing something, but whenever I click "Allow" on the IOS notifications popup the registerRemoteNotificationsRegistrationDenied callback is fired?
useEffect(() => {
const listeners: EmitterSubscription[] = [];
if (currentUser && !currentUserLoading && !notificationsRequested) {
setNotificationLoading(true);
Notifications.isRegisteredForRemoteNotifications().then(enabled => {
if (enabled) {
setNotificationsRequested(true);
}
setNotificationLoading(false);
});
const allowedListener =
Notifications.events().registerRemoteNotificationsRegistered(event => {
console.log('registerRemoteNotificationsRegistered');
checkNotificationConfig(currentUser, event).then(() => {
setNotificationsRequested(true);
setNotificationLoading(false);
});
});
const errorListener =
Notifications.events().registerRemoteNotificationsRegistrationFailed(_ => {
console.log('registerRemoteNotificationsRegistrationFailed');
setNotificationsRequested(true);
setTimeout(() => setNotificationLoading(false), 100);
});
const declinedListener =
Notifications.events().registerRemoteNotificationsRegistrationDenied(() => {
console.log('registerRemoteNotificationsRegistrationDenied');
setNotificationsRequested(true);
setNotificationLoading(false);
});
listeners.push(...[allowedListener, errorListener, declinedListener]);
} else {
setNotificationLoading(false);
}
return () => {
listeners.forEach(listener => listener?.remove());
};
}, [checkNotificationConfig, currentUser, currentUserLoading, notificationsRequested]);