I'm having issues with the event listeners on OneSignal.
After login, I manually do "OneSignal.registerForPushNotifications()".
This works, the prompt dialog shows on device.
Before I call this, I set 2 eventListeners: 'received' and 'registered'.
These never get called.
Any ideas?
componentWillMount() {
OneSignal.addEventListener('received', this.onPushReceived);
OneSignal.addEventListener('registered', this.onPushRegistered);
OneSignal.registerForPushNotifications();
}
onPushReceived (notif) {
console.log('PUSH RECEIVED', notif);
}
onPushRegistered (notifData) {
console.log('DEVICE PUSH REGISTERED', notifData);
}
Could it have to do with the app being deployed with 'debug' instead of 'release' scheme?
I did this in node_modules/react-native-onesignal:
- (void)handleRemoteNotificationsRegistered:(NSNotification *)notification {
NSLog(@"XCODE PUSH REGISTERED");
[self.bridge.eventDispatcher sendAppEventWithName:@"remoteNotificationsRegistered" body:notification.userInfo];
}
No log message was shown in Xcode.
So the native code doesn't handle the registered event...
I also cannot get the received event to fire when the app is in the background, but it does fire when the app is active.
Related to #182 and #209
We also have an issue, that I think it's related to this.
When out app has been in the background for a while the user gets the OneSignal notification, but when opening the app from the notification, the app doesn't get the notification payload.
Any update on this? Can't seem to get 'registered' to fire, and 'ids' takes about 30 seconds from a cold start.
+1
Can't get the registered event to fire handler. I need that to dismiss a modal..
@almirfilho I had a similar issue with the registered event not firing. I ended up moving the event listener initialization into index.ios.js and its been working fine since. I think the event was simply firing too early before I had setup the listener.
@michael-gillett thanks for your reply. I've tried the same thing already, no success yet.
I don't know much about Objective C, but after spending some time trying to figure out what's going on, I've noticed the handler method for the registered event, handleRemoteNotificationsRegistered is defined but is actually NOT being referenced from anywhere else in the codebase. So, maybe some native code is missing?
I'm using the latest version, 3.0.5.
Have the same problem with registered event, used ids as a workaround.
I have the same problen with registered event and received event. Do you have a solution to it?
Thanks you!
@lehoi2195 Use 'ids'
No way for me as well to have 'received' or 'opened' events triggered in any situation.
Any news about that pull request or workarounds?
Thank you!
Thanks, I opened up another issue before I came across this ... sorry but was just concerned as to why the event listeners weren't consistently being fired.
https://github.com/geektimecoil/react-native-onesignal/issues/372
Most helpful comment
We also have an issue, that I think it's related to this.
When out app has been in the background for a while the user gets the OneSignal notification, but when opening the app from the notification, the app doesn't get the notification payload.