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
389 stars 115 forks source link

Fix logout() when push subscription doesn't exists #1194

Closed jkasten2 closed 2 months ago

jkasten2 commented 2 months ago

Description

One-Line Summary

Fix OneSignal.logout() so it doesn't throw an error if there isn't a push subscription.

Details

A push subscription only exists if the end-user accepted notifications at some point. OneSignal.logout() made this bad assumption it always existed.

The fix is to check this and create a local only user instead of making a call to OneSignal if there isn't a push subscription.

Validation

Tests

Tested on Chrome Version 128.0.6613.138 on Windows 11 23H2 Scenarios:

  1. OneSignal.login("A");
  2. OneSignal.User.addEmail("a@a.com");
  3. OneSignal.logout();
  4. OneSignal.User.addEmail("b@b.com");
  5. Observe b@b.com was added to the correct User.

Info

Checklist

Programming Checklist Interfaces:

Functions:

Typescript:

Other:


Related Tickets



This change is Reviewable