exponea / exponea-react-native-sdk

MIT License
8 stars 13 forks source link

How to get push token? #4

Closed jdtavisca closed 4 years ago

jdtavisca commented 4 years ago

is there any way documented for react native, by which i can get push token? and send them to backend which can set it in google_push_notification_id or apple_push_notification_id.

wassil commented 4 years ago

With automatic push notification tracking, the token is tracked automatically. I'm not sure why you want to track it manually. Can you please describe your use-case a bit?

jdtavisca commented 4 years ago

How library will know, that it has to set this token against which member?, differentiated by registered attribute.

Because, I have some scenarios around notification, which only sends notification to some members based on scenario.

Apart from this, we have other DB's where I would like to store this token.

wassil commented 4 years ago

The SDK uses a customer to track data. A customer is created when the SDK is first started and all the events(including push notification token) will be tracked for that customer. If you need to create a new customer(e.g. user has logged in/logged out) you can use .anonymize() method. If you identify customer with an existing id, Exponea backend will automatically merge the customer into an existing one.

It's completely fine to only send push notifications to specific customers, I don't really see how that's related to tracking push tokens.

Currently we don't support getting the push token directly in react native, because if you actually want to use the token for anything useful, you would have to make changes in the native part of the SDK - implement your own FirebaseMessagingService, notification callback on iOS. It is possible to get the token, but you'd have to do it in native.

jdtavisca commented 4 years ago

thanks!!