React-native-push-notification: onRegister function not calling in android

Created on 20 Sep 2016  路  13Comments  路  Source: zo0r/react-native-push-notification

I was trying to generate the token in android but the onRegister function wont fire. Did I missing something.
here is my code

import React, {Component} from 'react';
import PushNotification from 'react-native-push-notification';

export default class PushController extends Component{
componentDidMount(){
PushNotification.configure({
onRegister: function(token) {
console.log( 'jitender:', token );
},

        onNotification:function(notification){
            console.log('NOTIFICATION:', notification);
        },
        requestPermissions:true,
        popInitialNotification:true
    })
}

render(){
    return null
}

}

Most helpful comment

Thought I'd drop a note here that this issue also arises if -- during the android setup -- you add the XML snippet (3 <receiver>s and 2 <service>s) inside of the <activity> tag like I did on accident -_-. They need to be immediate children to the <application>.

The error that shows up in logcat in this scenario is:

W ActivityManager: Unable to start service Intent { cmp=com.goodbookey.mobile.dev/com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService (has extras) } U=0: not found

All 13 comments

You need to supply a GCM sender id.

Will it work in android simulator?

But do you have a GCM sender id? This is not the same as thing as the token.

I tried using both Firebase's project number and app id as senderID, but onRegister is still not being called.

I noticed that Firebase suggests we add some dependencies to the project com.google.gms:google-services:3.0.0, should them be added, too?

As far as I know the readme instructions are correct. You get your sender id from google in a document called google-services.json. Do you have this file?

Yes, but it didn't work.
I ended up switching to react-native-fcm for now, but will provide update in case I'm able to go back to react-native-push-notification.

This is a problem, Parse Server doesn't yet support FCM - so I need it to work on my Android application. But no luck :(

same issue here, i have set senderID from my GCM project, and onRegister never called..

this occurs on iOS as well

Hi everyone, I'm having the same issue. I read some answers, on the issues list, and I need to run after the configure requestPermissions() but that didn't work either.

Thought I'd drop a note here that this issue also arises if -- during the android setup -- you add the XML snippet (3 <receiver>s and 2 <service>s) inside of the <activity> tag like I did on accident -_-. They need to be immediate children to the <application>.

The error that shows up in logcat in this scenario is:

W ActivityManager: Unable to start service Intent { cmp=com.goodbookey.mobile.dev/com.dieam.reactnativepushnotification.modules.RNPushNotificationRegistrationService (has extras) } U=0: not found

Happens for me also, any update?

The readme is either incorrect or I'm missing something. Where it says to only add things to your AndroidManifest.xml if you want local notifications, you actually have to do those steps anyway. At least some of them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

selimonline picture selimonline  路  3Comments

Benzer1406 picture Benzer1406  路  3Comments

DanDance picture DanDance  路  3Comments

anativ picture anativ  路  3Comments

Kiran0791 picture Kiran0791  路  3Comments