OneSignal / OneSignal-Website-SDK

OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
383 stars 115 forks source link

[Bug]: OneSignal.registerForPushNotifications does not re-subscribe the player ID (subscription status is still "Not Subscribed") #1152

Open jpdelmundo opened 5 months ago

jpdelmundo commented 5 months ago

What happened?

Setup works initially the first time the user accepts/allows the browser notification setting. However, when I manually disable the browser notification and decided to re-enable it again after some time (a few minutes), and calling OneSignal.registerForPushNotifications() does not re-subscribe the player ID.

What browsers are you seeing the problem on?

Chrome (Chromium)

What operating system are you running?

Windows 11 Pro 23H2 22631.2861

Steps to reproduce?

1. Setup
var OneSignal = OneSignal || [];
          OneSignal.push(["init", {
            appId: '<app id here>',
            autoRegister: false,
            notifyButton: {
              enable: false /* Set to false to hide */
            },
            ,welcomeNotification: {
                "title": "You're almost done!",
                "message": "Please click here to log in to your account and configure your notifications.",
                "url": "https://mydomain.com/welcome-message"
            }
                      }]);

2. Make sure browser notification setting is allowed, then visit the page with the setup above.
3. Note the player/subscription ID from console: OneSignal.getUserId().then(r=>console.log(r))
4. Verify the player ID Subscription Status in dashboard.onesignal.com App > Audience > Subscription (should show check mark)
5. Disable / disallow browser notification setting. Reload.
6. Wait some time.
7. Verify the player ID Subscription Status in dashboard.onesignal.com App > Audience > Subscription (should show Not Subscribed)
8. Enable / Allow browser notification setting. Reload. Wait some time.
9. Verify the player ID Subscription Status in dashboard.onesignal.com App > Audience > Subscription (still showing Not Subscribed)
10. In browser console run: OneSignal.registerForPushNotifications(). Wait some time.
11. Verify the player ID Subscription Status in dashboard.onesignal.com App > Audience > Subscription (still showing Not Subscribed)

What did you expect to happen?

I expected the player ID status to be subscribed (check mark under "Subscription Status")

Relevant log output

No response

jpdelmundo commented 5 months ago

I also called OneSignal.setSubscription(true) manually in the web console after OneSignal.registerForPushNotifications(), and still the status is "Not Subscribed".

jkasten2 commented 5 months ago

@jpdelmundo Thanks for reporting this issue. I confirmed this happens in v15 of the OneSignal SDK. I also tested in v16 and can confirm this is no longer an issue.

Can you update to v16 by following following the details in the release notes? https://github.com/OneSignal/OneSignal-Website-SDK/releases/tag/160000

jpdelmundo commented 5 months ago

@jkasten2 Thank you for your response and confirming this issue is a bug.

I confirmed this happens in v15 of the OneSignal SDK

If this is a confirmed bug, when will this be fixed on v15?

I also tested in v16 and can confirm this is no longer an issue.

We are not yet planning on upgrading to v16.