Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

onPushTokenReceivedCallback never called #253

Closed
burkard opened this issue Jan 6, 2017 · 12 comments
Closed

onPushTokenReceivedCallback never called #253

burkard opened this issue Jan 6, 2017 · 12 comments
Labels

Comments

@burkard
Copy link

burkard commented Jan 6, 2017

Hi,

The plugin works right, I can initialize it with the code below, and even login anonymously.

firebase.init({
                onPushTokenReceivedCallback: function(token) {
                    console.log("Firebase plugin received a push token: " + token);
                },
                
                onMessageReceivedCallback: function(message) {
                    console.log("MESSAGE: "+JSON.stringify(message));
                }
            }).then(
                (instance) => {
                    console.log("firebase.init done =>> "+instance);
                    
                    firebase.login({
                        type: firebase.LoginType.ANONYMOUS
                    }).then(
                        function (result) {
                            console.log(JSON.stringify(result));
                            firebase.getAuthToken({forceRefresh: false}).then((data)=>{

// this function IS CALLED!
console.log("data: "+JSON.stringify(data));
});

                        },
                        function (errorMessage) {
                            console.log(errorMessage);
                        }
                    );    
                },
                (error) => {
                    console.log("firebase.init error: " + error);
                }
            );

The problem is the function onPushTokenReceivedCallback is NEVER called.

What am I doing wrong?

@balasasidhar
Copy link

balasasidhar commented Jan 10, 2017

@burkard are you running on a Google API's powered emulator ?

@burkard
Copy link
Author

burkard commented Jan 10, 2017

@sasidhar678 no, I'm testing on two real devices (LG Leon 4g and Moto G2), both with Google Play Services, Gmail account, etc.

Have you experienced it too?

@balasasidhar
Copy link

Yes ! But now it's working fine with both emulator and real devices.

@burkard
Copy link
Author

burkard commented Jan 10, 2017

Could you please tell me how did you solved the issue?

@balasasidhar
Copy link

In my case, previously I tested on a Non-Google API's emulator.

Did you add the two services in AndroidManifest.xml file ?

@burkard
Copy link
Author

burkard commented Jan 10, 2017

Yes, the services tags were added.

I'll try to test on the emulator using a different system image. Meanwhile, I'll be using the nativescript-push-notification plugin.

@sagesan
Copy link

sagesan commented Feb 9, 2017

I just had the same problem, you should try checking out the

node_modules\nativescript-plugin-firebase\platforms\android\include.gradle

for

// Uncomment if you want FCM (Firebase Cloud Messaging)

compile "com.google.firebase:firebase-messaging:10.0.+"

If the compile... line is commented, that's the reason you don't ever receive tokens - messaging is not compiled in, and hence the callback is registered, but app never registers in Firebase for messages.

Un-comment, remove platform, build anew and let me know if that helped.

@manishmlv50
Copy link

I am facing the same issue. I receive the notification and the addOnMessageReceivedCallback() is called. But when the app is terminated. No notification is received by the device. Also, onPushTokenReceivedCallback() is never called when firebase is initiated. I have checked that the two services are added in AndroidManifest.xml and even firebase messaging is uncommented in the include.gradle

What could be the issue?

@Nikoms
Copy link

Nikoms commented Jun 19, 2017

I had the same issue.
I removed hooks/platform/node_module et used tns-android "version": "3.1.0-next-2017-06-12-1864" and it worked

@samuelzv
Copy link

I followed the steps

tns platform remove android
tns platform add android
did the trick :)

@nakorndev
Copy link

Pass 1 year still not fix this issue? I still have this problem.

@EddyVerbruggen
Copy link
Owner

@nakorndev Oh, sorry, forgot to close.

Repository owner locked as resolved and limited conversation to collaborators Oct 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants