React-native-onesignal: addEventListener('ids', this.onIds) does not work (or I misunderstand something )

Created on 6 Jul 2017  ·  11Comments  ·  Source: OneSignal/react-native-onesignal

Ok, so I configured onesignal with rn as is in readme, and it works. Notifications are coming. However I also need to get device (player) id, so it can be handled by my api. As I understood, I should use:

componentWillMount() {
    OneSignal.addEventListener('ids', this.onIds);
}

onIds(device) {
    console.log('Device info: ', device);
}

However, it never triggers. Am I doing sth wrong? How can I get device ids of current user?

Most helpful comment

i'm also facing this issues, device can received push notification but can't get ids.
Edited: fixed by add OneSignal.configure() after addEventListener

All 11 comments

@Kacoze Feedbacks are appreciated if you managed to resolve your issue.

any solutions for this issue? facing the same.

i'm also facing this issues, device can received push notification but can't get ids.
Edited: fixed by add OneSignal.configure() after addEventListener

+1

Thanks @arma7x <3

come on. Its work. why documentation of one signal was weak!!

In previous version, we don't need add that line, but don't know why they don't update the docs!!!

Thanks for solution. Just found in docs:
Please note that calling OneSignal.configure() causes the ids event to fire.

@arma7x Fixed my issue, Thank you.

Not fix for me

I'm getting an error RNOneSignal.configure is not a function after updating OneSignal to the latest version, was it deprecated/ removed in the latest version?
https://github.com/geektimecoil/react-native-onesignal/issues/844

Was this page helpful?
0 / 5 - 0 ratings