customerio / customerio-reactnative

MIT License
23 stars 11 forks source link

Initializing on iOS results in 2 separate devices #179

Closed billyjacoby closed 1 year ago

billyjacoby commented 1 year ago

SDK version: 2.3.3 & 3.1.6

Environment: Development or Production Development

Are logs available?

Describe the bug

When initializing a device via iOS (simulator or physical device) that device shows up under devices two separate times. Only one of the device tokens works to display a test notification though.

To Reproduce

Expected behavior

Screenshots

Additional context

mrehan27 commented 1 year ago

Thank you for reaching out. To better understand and address the issue, can you please confirm the following?

  1. Can you please clarify what do you mean by separate times exactly? Is this the same device or different ones? If user uses the same identifier/email on multiple devices, all of them will be listed under the same person in the dashboard.
  2. Were you expecting notifications to work on simulators? Please note that notifications will not function on simulators for iOS. You need to test them on real devices.
  3. Does your react native app uses the registerDeviceToken method? If yes, can you please provide more details on its implementation and share the use case for using it.
  4. Are you using APNS or FCM for handling notifications?
  5. Can you reproduce the issue every time? If yes, can you please provide the steps to reproduce it.
  6. Any additional information related to the issue that can be helpful.

Appreciate your cooperation in providing these details. This will help us investigating the root cause and fixing the problem.

billyjacoby commented 1 year ago
  1. See screenshot: Screenshot 2023-07-25 at 12 44 04 PM These devices are the same exact device, but only the bottom one will successfully receive a push notification. They are both updated at the same times though.
  2. Notifications are working on both the simulator and physical devices.
  3. We are not using the registerDeviceToken method.
  4. APNs currently.
  5. Yes, simply opening the application on any new device will show two separate devices under that user as registered.
billyjacoby commented 1 year ago

Sorry just an update - we are calling the registerDeviceToken method, we're calling it after identifying a user.

Should we only be doing that on Android since it seems to be handled by the native iOS code?

mrehan27 commented 1 year ago

Thanks for the updates @billyjacoby. This might be duplicating the device. Can you please try removing calls to registerDeviceToken and see if it resolves the issue for you?

For clarity on registerDeviceToken, it may only be required in cases where multiple notification services are added to your app, and our SDK fails to call it at the right time. In most situations, you should not need to call it manually. Our SDK attempts to call this automatically for you on both Android and iOS. If you don't see the device instantly, relaunching the app should display your device on the dashboard.

Please let us know if this doesn't work, so I can suggest the next steps and we can further debug this with you.

billyjacoby commented 1 year ago

So it looks like I do still need to make the call on Android, but after removing on iOS can confirm that things seem to be working as expected now. Thanks a ton for the quick help with this!

mrehan27 commented 1 year ago

Glad it worked for you. Can you please confirm if the token registered by the SDK was the correct one and if it's working fine for you? I just want to ensure that there are no action items for us to improve on this.

For Android, the SDK attempts to register it automatically for most cases. Can you please share why you needed it for Android? If possible, we can address any edge case, and you might be able to remove calling it for Android too in the future. Can you please confirm the following:

Thank you for your feedback. Your input helps us improve the SDK. We appreciate your support!

billyjacoby commented 1 year ago

The token registered via native code for the iOS SDK was the correct token - when calling registerDeviceToken from iOS it seems that we were passing in a token fetched from Firebase when we are managing notifications via APNS and not FCM for iOS.

It seems that removing the same call for Android users will also let the SDK make the call properly and still work as expected.

So I'll be removing this RegisterDeviceToken call from all of our RN code! Thanks for all of the help!

mrehan27 commented 1 year ago

Thanks a lot for the confirmation. Glad to hear that it worked well for you. We appreciate your cooperation.