Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send device token from a React Native app #762

Closed
tomrom-pomelo opened this issue Feb 21, 2023 · 2 comments
Closed

How to send device token from a React Native app #762

tomrom-pomelo opened this issue Feb 21, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@tomrom-pomelo
Copy link

tomrom-pomelo commented Feb 21, 2023

Summary

Though this discussion has been brought up before in #144, #170, #532, and #541, there still seems to be no documented workaround or built-in solution for sending a device token from a React Native app. This is critical for syncing to certain destinations like customer.io.

I'll summarize the previously proposed solutions:

  • From #144 - use a middleware. However, this does not work for app lifecycle events
  • From #524 - use a plugin. However, there seemed to be issues with the context not existing
  • From #541 - use onContextLoaded within a plugin. This solution seems to work okay, but requires the client to manually re-set every property in the device object (no deepmerging is supported).

None of these solutions seem to work completely without major caveats.

Proposed Solution

It would be great to have an officially sanctioned/well-documented way to set the token in Segment using the analytics-react-native lib. It would be even better, of course, to have this be a part of the core library.

@tomrom-pomelo tomrom-pomelo added the enhancement New feature or request label Feb 21, 2023
@alanjcharles
Copy link
Contributor

Hi @tomrom-pomelo - thanks for reaching out! We have just released @segment/analytics-react-native-plugin-device-token. We decided against adding device token collection to core since Firebase Cloud Messaging is the standard dependency for Android device token generation and did not want to add another dependency to core for people who don't need it. This plugin also has the ability to collect the APNS value from iOS builds, but additional iOS setup is required there anyway. It's not the perfect solution, but one we think covers the most use cases without impacting users who don't need it. Help it helps!

@tomrom-pomelo
Copy link
Author

Nice, thank you. We use expo's push notification service not FCM, so we'll likely just copy this plugin and replace it with calls to expo-notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants