-
Notifications
You must be signed in to change notification settings - Fork 195
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
Support put device token to life cycle events #144
Comments
@quyentran-agilityio I have the same issue. |
The iOS native library auto-adds it, we use this middleware for android import {
Notification,
Notifications,
Registered,
} from 'react-native-notifications';
// global to store token
let deviceToken: string | null = null;
// called at startup
export const registerforPN = () => {
if (Platform.OS === 'android') {
Notifications.registerRemoteNotifications();
Notifications.events().registerRemoteNotificationsRegistered(
(event: Registered) => {
deviceToken = event.deviceToken;
},
);
}
};
// middleware for this library
export const pnMiddleware: Middleware = payload => {
const {next, context} = payload;
if (Platform.OS === 'android' && deviceToken !== null) {
if (!context.device) {
context.device = {token: deviceToken};
}
}
next(context);
}; |
@adamjuhasz that is a VERY clever work around, I dig it. We're gonna make this easier though. |
This is only working for custom events. Is there any wayout to set data in context for default lifecycle events? |
I'm having a same issue. In our set up we have Any idea? |
Hi guys, My react native app need to implement push notifications that required put device token to segment life cycle events. Does segment react-native lib support to add device token to life cycle events?
Something like this: https://segment.com/docs/connections/sources/catalog/libraries/mobile/ios/#how-do-i-use-push-notifications
https://segment.com/docs/connections/destinations/catalog/customer-io/#device-token-set-up
The text was updated successfully, but these errors were encountered: