question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onRegister is not being called

See original GitHub issue

Hi there, I am using react-native 0.30.0 and react-native-push-notification 2.0.2 and an Android device and have set up everything like in the README but when I call

var PushNotification = require('react-native-push-notification');

PushNotification.configure({
    onRegister: function(token) {
        console.log( 'TOKEN:', token );
    },
    onNotification: function(notification) {
        console.log( 'NOTIFICATION:', notification );
    },
    senderID: "MY GCM SENDER ID",
});

nothing happens (neither in logcat nor anything else).

Do you know what the issue may be or how to debug this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:18

github_iconTop GitHub Comments

15reactions
sajjad26commented, Aug 12, 2016

Hi i am using ReactNative 0.31 and com.google.android.gms:play-services-gcm:8.1.0 with a valid project id but the onRegister callback is not triggering neither on the real device nor on emulator. This is what i have so far

PushNotification.configure({
    onRegister: function(token) {
        ToastAndroid.show(`TOKEN : ${token}`, ToastAndroid.SHORT);
        console.log( 'TOKEN:', token );
    },
    onNotification: function(notification) {
        console.log( 'NOTIFICATION:', notification );
    },
    senderID: "12345",
    popInitialNotification: true,
    requestPermissions: false
});
PushNotification.requestPermissions();

Am i missing some thing ? BTW I am upgrading the application from 0.25 to 0.31 and it is working in the old application.

4reactions
BigPun86commented, Aug 18, 2016

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

onRegister is never called (on device) · Issue #678 - GitHub
I got iOS working, got the token, and saved to the back-end where I send remote push notifications. But for Android, onRegister is...
Read more >
React Native onRegister event not working (iOS)
This function never gets called. It doesn't matter if I have requestPermissions:true or not PushNotification.configure({ onRegister: ...
Read more >
react-native-push-notification Code Examples - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues ... (optional) Called when Token is...
Read more >
Working with API - AWS Amplify Docs
Push Notifications. Working with API. JavaScript is not supported on this page. Please select one of the following: React ...
Read more >
When to use OnRegister versus other Component lifecycle ...
OnRegister seems to get called even when… ... the functions called during initialization and when/if they will be called in editor or not: ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found