react-native-onesignal icon indicating copy to clipboard operation
react-native-onesignal copied to clipboard

Getting playerId in react-native android

Open shubham-matale opened this issue 8 years ago • 1 comments

Can you plz tell me how to get player id in react-native android. It's not mentioned in documentation. Please Help me

shubham-matale avatar Aug 22 '18 17:08 shubham-matale

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
}

anniewey avatar Aug 23 '18 09:08 anniewey