react-native-push-notification: onRegister is never called (on device)

I’ve spent countless hours trying to debug this, and although PushNotification.configure({..}) is called, the onRegister callback never fires — I’ve set requestPermissions to true, and even tried calling it manually; it still never fires. Currently I’m running it on an ASUS Zenfone Android 7.0 device, but just cant seem to get the token

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 16
  • Comments: 34 (1 by maintainers)

Most upvoted comments

@Amnesthesia To test, I found using PushNotificationIOS.addEventListener('registrationError', console.log) EXTREMELY useful, it showed me the exact reason of why it was failing.

This fixed it for me – I had to go into XCode > Project > Capabilities and turn on Push Notifications. Then the onRegister() callback started firing.

Guys, for iOS you should do this: https://stackoverflow.com/questions/27324020/no-valid-aps-environment-entitlement-string-found-for-application-on-app-store

If you already done setup tutorial for this library, you might be forgotten to setup Push Notifications in Capabilities panel in XCode.

If nothing happend, try to catch error using this code (for iOS only):

PushNotificationIOS.addEventListener('registrationError', (e) => { alert(JSON.stringify(e)) });

Ok guys, ive solved this. Here is my post, check it out: https://github.com/zo0r/react-native-push-notification/issues/697

@Amnesthesia + 1 Android onRegister is never called. I got iOS working, got the token, and saved to the back-end where I send remote push notifications. But for Android, onRegister is never called with the same code in configure. So, can’t get the token. I’ve spent hours on this too.

I’m also having trouble with Android onRegister. Tried everything in AndroidManifest.xml. Any ideas?!

onRegistrationError also not triggering, only trigger when i use simulator. when i run app on device, both onRegister and onRegistrationError not trigger.

so any solution? after a days of efforts, im thinking it was a total waste of time to go for this half documented project altogether. This method never gets called, so cant get token - how will I get remote push working?!!

hi @Dallas62 @student-t , its for ios and in my case i’ve setup each and everything but not getting call onRegister.

Just found something really interesting inside the apple docs!

https://developer.apple.com/library/archive/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG21

No Delegate Callbacks When the first push-capable app is installed, iOS or OS X attempts to establish a persistent network connection to the push service that will be shared by all push-capable apps on the system. If neither delegate callback application:didRegisterForRemoteNotificationsWithDeviceToken: nor application:didFailToRegisterForRemoteNotificationsWithError: is called, that means that this connection has not yet been established.

So after adding a sim card into my testing device – which was already connected by wifi – it seems to ping the apple services again and it start working. So my issue resolved by putting SIM card to the phone and it starts working. thanks for your help. especially @Dallas62 thanks a lot, you are really helpful.

yes, everything is done but no luck.

@Dallas62 hi, i’m not getting device token on ios, can you please help me out, i’m using latest version ^4.0.0. Thanks