React-native-push-notification: onRegister not getting called (Android)

Created on 11 Jan 2017  路  11Comments  路  Source: zo0r/react-native-push-notification

I can't seem to get remote push notifications to work in my app(Android) cause I can't get the token to fire back to the server. So far have not tried on iOS
RN version: 37-39.2
Push notification version: 2.2.0/1

I can fire a local notification and see that the PushNotification.configure has been run since the onNotification callback works, but I don't get the onRegister callback

In the build.gradle I have tried multiple versions of play-services-gcm, from 8.1.0 to 9.0.1 to 10.0.1 but nothing works. I have placed the PushNotification.configure call right in the beginning of the app, so I should expect to see the registration there?

I am running the code on the device. Can't seem to figure out what is wrong and there are no error messages thrown.

Build.gradle
`dependencies {
compile project(':react-native-vector-icons')
compile project(':react-native-i18n')
compile project(':react-native-device-info')
compile project(':react-native-config')
compile project(':react-native-audio-toolkit')
compile project(':react-native-image-crop-picker')
compile project(':react-native-photo-view')
compile project(':react-native-push-notification')
compile ('com.google.android.gms:play-services-gcm:8.1.0') {
force = true;
}

compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules

}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.getRequested().getGroup() == 'com.google.android.gms') {
// If different projects require different versions of
// Google Play Services it causes a crash on run.
// Fix by overriding version for all projects.
details.useVersion('9.6.1')
}
}
}`

Most helpful comment

Added correct permissions to AndroidManifest, still not getting a response..

All 11 comments

I have the same issue. Any thoughts on this?

Getting this issue too. Any solution?

@shoumma I've decided to switch to https://github.com/evollu/react-native-fcm instead for Android and native PushNotificationsIOS for IOS

I had the same issue.
The solution was to add the add the correct permissions in AndroidManifest.xml.
The callback is now correctly called.

Added correct permissions to AndroidManifest, still not getting a response..

@atebit did you insert the senderID? Are you using a real device?

SenderID was the problem.. Yes using a real device. Thanks!

Got the same problem. Found this issue after two days.
I'm using a real device too and @manuTro was right, was the senderID. For the ones (like me) who don't know how to get the senderID check out this article.

I think this could be a nice addition on the readme.

For me the solution was to include

<service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService"/>

in AndroidManifest.xml

I was under the impression that running react-native link would add everything that's needed to the manifest but this line is needed for the internal workings of this repo for remote push registration.

No longer an issue for me.

i have found this same issue. What SenderID you are using. Please clarify

Was this page helpful?
0 / 5 - 0 ratings