react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

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

Open reinevan opened this issue 1 year ago • 6 comments

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:

  • When the user logs in, I invoke:

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?

  • [X] iOS
  • [X] Android

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

reinevan avatar Aug 15 '24 08:08 reinevan

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

jennantilla avatar Aug 15 '24 20:08 jennantilla

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

BrantK avatar Aug 29 '24 03:08 BrantK

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

reinevan avatar Sep 16 '24 07:09 reinevan

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

SKHRAPP avatar Sep 30 '24 07:09 SKHRAPP

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

zguo123 avatar Oct 08 '24 17:10 zguo123

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?

nan-li avatar Oct 08 '24 18:10 nan-li