OneSignal / react-native-onesignal

React Native Library for OneSignal Push Notifications Service
Other
1.57k stars 374 forks source link

[Bug]: App still receives notifications for the previous external ID if I call OneSignal.logout() and OneSignal.login() for other external ID #1730

Open reinevan opened 3 months ago

reinevan commented 3 months ago

What happened?

I have a React Native Expo application where I use react-native-onesignal v 5.2.0 to receive push notifications. In the app users can log in / log out:

OneSignal.login(externalId) OneSignal.User.addEmail(emailAddress) OneSignal.User.addTag('email', emailAddress) OneSignal.User.addTag('phone', phoneNumber)

When the user logs out, I invoke:

OneSignal.logout()

When some updates happen on the backend, I send push notifications to related users using "include_external_user_ids" field in the REST API call.

The scenario is as follows:

User A logs in, the app receives push notifications sent to User A. User A logs out. User B logs in.

As the result the app does NOT receive push notifications for User B, but still receives notifications for User A.

Steps to reproduce?

1. Call OneSignal.initialize(OneSignalAppId)
2. Call OneSignal.login(externalIdA)
3. Send some push notifications for externalIdA, test that they are received on your device
4. Call OnSignal.logout()
5. Call OneSignal.login(externalIdB)
6. Send some push notifications for externalIdB, test that they are NOT received on your device
7. Send some push notifications for externalIdA, test that they are received on your device

What did you expect to happen?

I expected app to stop receiving push notifications for external ID if I invoked OneSignal.logout() and want to receive push notifications for external ID if I invoked OneSignal.login(externalId).

React Native OneSignal SDK version

Release 5.2.0

Which platform(s) are affected?

Relevant log output

No response

Code of Conduct

jennantilla commented 3 months ago

Hello @reinevan thanks for reaching out! Could you please share the debug log reproducing this behavior? Thanks!

BrantK commented 2 months ago

I am seeing the same issue. Is there a workaround for this?

reinevan commented 2 months ago

Hello @reinevan thanks for reaching out! Could you please share the debug log reproducing this behavior? Thanks!

Thanks for looking at it! Please find the log attached:

onesignal.txt

SKHRAPP commented 1 month ago

@jennantilla any update from this issue still getting previous employee notification after oneginal.logout()

zguo123 commented 1 month ago

I am also facing the same issue. I would love a solution asap!

nan-li commented 1 month ago

Hi @reinevan thank you for the logs. I see the issue is that the first login(externalId: 1eafc97a-9612-4bd1-bb98-a3610570f49d) encountered a tag entitlement error. Therefore, the subsequent logout and login(externalId: b780b91c-e302-4079-b41b-e6d945122a02) are blocked and they don't actually successfully logout and login to those users.

POST - STATUS: 409 - Body: {"errors":[{"code":"entitlements-tag-limit","title":"The tags for this user exceed the limit for this organization's plan. Please remove existing tags or upgrade your plan to add more tags"}]}

You marked this as affecting both Android and iOS, can you confirm you also experienced this behavior on iOS?