phonegap / phonegap-plugin-push

Register and receive push notifications
MIT License
1.94k stars 1.91k forks source link

Don’t receive push notification on android with FCM {"error":"NotRegistered"} #2205

Open YvesAmmann opened 6 years ago

YvesAmmann commented 6 years ago

Expected Behaviour

Receive push notification on android in foreground and background mode.

Actual Behaviour

Push notification on android was not delivered with my own sending service and also not with the firebase console. On iOS everything works as expected.

The call push.on('registration') fires a token to my backend service (e.g. "xxx5eqQ9qHw:APA91bFjaaGTxYYnxXeWZfU-5JDfnCY7v2UCnMMpIWAKtDT1-iVzVbPZTL4TG2aSuf7DGul03JOqfJkDClJiekJxXj4JrlzpHQG0qqmRL7WMpzCYSDTKORsrh-961m4-PNz72N4wtxxx").

Now I’m send the JSON to the FCM service and the response is:

{"multicast_id":0004629238446017000,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 7.0

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Sony Xperia

Cordova CLI version and cordova platform version

cordova version 7.1.0 cordova platform version android 6.3.0

Plugin version

phonegap-plugin-push 2.1.2

Sample Push Data Payload

{"registration_ids":["xxx5eqQ9qHw:APA91bFjaaGTxYYnxXeWZfU-5JDfnCY7v2UCnMMpIWAKtDT1-iVzVbPZTL4TG2aSuf7DGul03JOqfJkDClJiekJxXj4JrlzpHQG0qqmRL7WMpzCYSDTKORsrh-961m4-PNz72N4wtxxx"],"data":{"body":"Test","sound":"default","badge":1},"priority":"high"}

My question

Why is the token successfully send to my backend, but the FCM service give an error "NotRegistered"? Thanks in advance!

macdonst commented 6 years ago

@YvesAmmann Seems like the registration id you have is for a different project. Make sure your google-service.json is for the same project as where you are sending.

YvesAmmann commented 6 years ago

Hi @macdonst

I’ve downloaded the google-services.json from https://console.firebase.google.com/ and the file is in the builded package. Also the project_number is the same.

Is it possible to refresh the token or something?

parmarkaushik15 commented 6 years ago

HI Same issue occure in my application. FCM every time send the {"error":"NotRegistered"} I am also used same Platform and Version (eg. Android 5.0 or iOS 9.2.1) Android 7.0

Plugin version phonegap-plugin-push 2.1.2

macdonst commented 6 years ago

@YvesAmmann I would try completely uninstalling the app and re-installing.

YvesAmmann commented 6 years ago

@macdonst Already done without success...

macdonst commented 6 years ago

@YvesAmmann how about some logs from when the app starts up and registers for push notifications?

adb locat | grep Push

YvesAmmann commented 6 years ago

@macdonst No log entrys for "Push".

    push.on('registration', function(data) {
        $$.ajax({
            type: 'GET',
            url: api_url
            data: {
                device_token: data.registrationId
            },
            dataType: 'text',
            async: true,
            timeout: 3000,
            success: function(response) {},
            error: function(xhr, type) {}
        });
    });

But this method will be invoked, because my api receives the token.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

macdonst commented 5 years ago

@YvesAmmann did you ever get this resolved? It seems crazy that you'd get a registration ID but not see any logs in logcat for "Push".

cikcoh commented 5 years ago

@macdonst Hi, i tried sending notifications using postman, i just copied registrationId from my app console.log. the registered id on android is successful, but the one in copied from ios keeps giving invalidRegistration or notRegistered. i have uninstall the app, resulting in new registrationId, copied the new id to postman but still getting the same error

amanbajpai commented 5 years ago

Hello Folks, I'm too facing the same issue, in my application, I am able to get push once I don't login into the app, after I logged in successfully, FCM says "not registered" as error.

using below dependencies: implementation "com.google.firebase:firebase-messaging:11.0.4" implementation "com.google.firebase:firebase-core:11.0.4"

Please revert me if somebody can help me out.

parmarkaushik15 commented 5 years ago

Hi which platform you want to send the notifications Recently I have also same problem occur for iOS but I have that solved it. Kindly share your screenshot then I can provide you the solution

cikcoh commented 5 years ago

@amanbajpai hi, this one works for me https://github.com/phonegap/phonegap-plugin-push/issues/2518

amanbajpai commented 5 years ago

@parmarkaushik15 I am looking for Android platform.

amanbajpai commented 5 years ago

@amanbajpai hi, this one works for me #2518

Yup but, I need for Android.

YogendraPatel commented 5 years ago

@parmarkaushik15 Please help me. i have face same problem for iOS.

YogendraPatel commented 5 years ago

Hi which platform you want to send the notifications Recently I have also same problem occur for iOS but I have that solved it. Kindly share your screenshot then I can provide you the solution

Please help me. i have face same problem for iOS.

ankur62 commented 5 years ago

@parmarkaushik15 @YogendraPatel I have same problem. I get error many times because of "error":"NotRegistered"}. I am getting same error @parmarkaushik15 for iOS. please tell me solution how you solved this problem

ankur62 commented 5 years ago

Hi which platform you want to send the notifications Recently I have also same problem occur for iOS but I have that solved it. Kindly share your screenshot then I can provide you the solution

I am also facing same issue for iOS

parmarkaushik15 commented 5 years ago

Hi which platform you want to send the notifications Recently I have also same problem occur for iOS but I have that solved it. Kindly share your screenshot then I can provide you the solution

I am also facing same issue for iOS

HI i have solve that issue. If you want to solve then contact me on skype : live:parmarkaushik15

parmarkaushik15 commented 5 years ago

@parmarkaushik15 Please help me. i have face same problem for iOS.

HI i have solve that issue. If you want to solve then contact me on skype : live:parmarkaushik15

cikcoh commented 5 years ago

@YogendraPatel @ankur62 For ios platform, please read this thread here https://github.com/phonegap/phonegap-plugin-push/issues/2518

Cordova project on Xcode10 is failure for FCM because of XCode's new build system. If you want to use Google FCM Push Notification with iOS device (Coding with Cordova / Ionic 3) try >this; Opening your cordova/ionic project in the Xcode IDE and change the build system in Workspace >Settings to "Legacy Build System". (Under the File Menu)

sanket684 commented 4 years ago

iam also facing same issuie for iso

imguccho commented 4 years ago

{"multicast_id":4314312645771955637,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}

tshavkat commented 4 years ago

I'm also facing same issuie for iOS

thedeephakani commented 3 years ago

I'm also facing same issue for android. {"multicast_id":8832974035271031658,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}

any solution for this.