react-native-push-notification icon indicating copy to clipboard operation
react-native-push-notification copied to clipboard

onRegister is never called (on device)

Open Amnesthesia opened this issue 8 years ago • 34 comments

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

Amnesthesia avatar Mar 17 '18 08:03 Amnesthesia

Same here, trying on iPhone7. Local notifications work.

jjant avatar Mar 18 '18 20:03 jjant

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

jjant avatar Mar 18 '18 21:03 jjant

same problem

cj4luv avatar Mar 27 '18 04:03 cj4luv

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?!!

Rah1x avatar Mar 28 '18 05:03 Rah1x

Same here! Android never working onRegister callback, anyone??

paruckerr avatar Mar 28 '18 21:03 paruckerr

same here, samsung A3.

julien-mustiere avatar Apr 01 '18 23:04 julien-mustiere

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

Rah1x avatar Apr 03 '18 07:04 Rah1x

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)) });

ErickVoodoo avatar Apr 08 '18 13:04 ErickVoodoo

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

dgurns avatar Aug 29 '18 15:08 dgurns

@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.

creightontaylor avatar Sep 24 '18 00:09 creightontaylor

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

ammichael avatar Sep 25 '18 19:09 ammichael

Ok guys, ive solved this. Here is my post, check it out: #697

it's ok for android, thank you very much!

lequangtuananh avatar Nov 14 '18 06:11 lequangtuananh

@dgurns thanks that solved it for me too.. wasted some good hours on that...

verybluebot avatar Dec 09 '18 15:12 verybluebot

I was having the same problem. For android add senderID: "123****" (sender key value) which are numeric value. It solved my problem. (For GCM its project number).

RajuDhungana avatar Aug 24 '19 03:08 RajuDhungana

@lequangtuananh I'm facing this same problem on Android, but I'm not using Firebase. Does your solution still apply to my scenario?

gabeDevlift avatar Jan 26 '20 22:01 gabeDevlift

I was facing this issue for several hours on my IOS device locally. Turns out the fix was to simply restart my XCode & rebuild 🤷‍♂️

marxlow avatar Apr 27 '20 13:04 marxlow

@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

ZishanK avatar Jul 16 '20 15:07 ZishanK

@ZishanK Test first solutions in this issues. This library is a wrapper of another iOS library (react-native-community/push-notification-ios), if there is any issue, it's not here 😉

Dallas62 avatar Jul 16 '20 15:07 Dallas62

Also, https://github.com/zo0r/react-native-push-notification#usage onRegistrationError has been added for the case there is an error on registration.

Dallas62 avatar Jul 16 '20 15:07 Dallas62

this is also not triggering, don't what's the issue there.

ZishanK avatar Jul 16 '20 15:07 ZishanK