Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerRemoteNotificationsRegistrationDenied being called even when "Allowed" clicked #1044

Open
hwhh opened this issue Jun 28, 2024 · 1 comment

Comments

@hwhh
Copy link

hwhh commented Jun 28, 2024

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]);

Copy link

stale bot commented Jan 31, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the 🏚 stale label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant