braze-react-native-sdk icon indicating copy to clipboard operation
braze-react-native-sdk copied to clipboard

[Bug]: Sending push notification to wrong user

Open HoangDilo opened this issue 10 months ago • 1 comments

Which Platforms?

iOS

Which React Native Version?

0.73.5

Which @braze/react-native-sdk SDK version?

9.0.0

Repro Rate

Really hight, especially after switching users

Steps To Reproduce

Example:

  1. import Braze from "@braze/react-native-sdk".
  2. Run the app
  3. //some logics for creating anonymous users (haven't logged in)
  4. const deviceId = DeviceInfo.getUniqueId();
  5. run: Braze.changeUser(anonymous_${deviceId})
  6. //set attributes of an anonymous user to Braze (both standard and custom attributes)
  7. //login first account, calling apis to get the UserId_1
  8. run: Braze.changeUser(UserId_1)
  9. //set attributes of an User to Braze (both standard and custom attributes)
  10. //Logout logic
  11. const anonymousId = AsyncStorage.getItem('anonymous_id') //get back the anonymous user id from storage
  12. //switch back to anonymous users and run: Braze.changeUser(anonymousId)
  13. //set attributes of an anonymous user to Braze (both standard and custom attributes)
  14. //Login with second account, calling apis to get the UserId_2
  15. run: Braze.changeUser(UserId_2)
  16. Creating test push notification, sending to the changed user

Expected Behavior

  • Receive the test push notification (correspoding with the current user that is logging in)
  • Seeing error message: "No matching token..." when trying to push the notification to UserIds not being used

Actual Incorrect Behavior

  • NOT receive the test push notification for the that is logging in.
  • Receive test push notification of OTHER user

Verbose Logs

No response

Additional Information

  • I have tried to debug this bug, even try to log the current userId from Braze (with Braze.getUserId) after each switching phase. The userId return is correct (receive correct logged in user Id and correct anonymous user id)
  • I also monitor the payload has been sent to Braze via sdk, and the user id sent to Braze is correct too
  • Until now, this bug only appears on IOS actual devices, after me switching the user many times

HoangDilo avatar Apr 24 '24 10:04 HoangDilo

Hi @HoangDilo,

Can you contact [email protected] with more information:

  • Please attach verbose logs when you are able to reproduce this issue
  • Are you able to reproduce this with actual campaign sends (instead of Test Sends)?
  • Can you repro this with our React Native sample app?
  • At times, it may take a little bit for APNs to send a push notification that is received on a device. It may help to try again after some time if you feel that the notifications take a long time to be received by the device
  • Add a link to this Github issue for reference

The Braze Support team should help with trying to reproduce this issue to diagnose the root cause.

Thanks!

hokstuff avatar Apr 24 '24 21:04 hokstuff

我也遇到同样的问题(I also encountered the same problem) Hope to resolve it quickly

wangbf11 avatar May 30 '24 07:05 wangbf11

For people who encounter this issue, we could fix it by manually configuring the IOS token. But it's kinda complicated

HoangDilo avatar May 30 '24 08:05 HoangDilo

For people who encounter this issue, we could fix it by manually configuring the IOS token. But it's kinda complicated

我已经解决了 哈哈今天困扰了我 1天了。抓包发现切换userid的时候 安卓发送了请求 ios没发送 ios有点不同 你要去 原生力把token拿到 传到rn来 然后 changeUser后 再注册一次registerPushToken 我抓包看到请求就正常了

wangbf11 avatar May 30 '24 12:05 wangbf11

@wangbf11 @HoangDilo Just to check, in your iOS code, are you implementing push functionality via configuration.push.automation, or the manual integration? It might be related to an issue that was recently fixed in 9.2.0 of our Swift SDK, which is pending an upcoming port to our React Native SDK.

jerielng avatar May 30 '24 14:05 jerielng

@wangbf11 @HoangDilo只需检查一下,在您的 iOS 代码中,您是通过 还是手动集成实现推送功能?这可能与我们 Swift SDK 9.2.0configuration.push.automation中最近修复的问题有关,该问题正在等待即将移植到我们的 React Native SDK。

ios的changeuse 不会触发 userId和pushtoken的绑定关系 需要手动调用registerPushToken(i参数:ios原生token)。

wangbf11 avatar May 31 '24 01:05 wangbf11

Hey all, the latest 10.0.0 version has been updated with our underlying Swift SDK version 12.0.0. This fix contains updates that upload push tokens more reliably when using the push automation features, particularly on changing users.

If you continue to see issues after upgrading, please send in some verbose logs and reproduction steps (in addition to code snippets of how you are integrating push notifications with our SDK) to [email protected]. Thank you!

jerielng avatar Aug 15 '24 20:08 jerielng