react-native-onesignal
react-native-onesignal copied to clipboard
Getting playerId in react-native android
Can you plz tell me how to get player id in react-native android. It's not mentioned in documentation. Please Help me
It's mentioned in the docs under Getting Player ID and Push Token https://documentation.onesignal.com/docs/react-native-sdk
componentWillMount() {
OneSignal.init("YOUR_ONESIGNAL_APPID");
OneSignal.configure(); //will trigger ids event to fire.
OneSignal.addEventListener('ids', this.onIds);
}
componentWillUnmount() {
OneSignal.removeEventListener('ids', this.onIds);
}
onIds(device) {
console.log('Device info: ', device); //your playerId
}