user6623857
user6623857

Reputation:

I get InvalidRegistration while sending notification to Android

I'm trying to send notification using php curl to android but I get this:

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

Im getting token in android with the below code:

public String getToken() throws IOException {
    return FirebaseInstanceId.getInstance().getToken();
}

Upvotes: 2

Views: 12725

Answers (4)

Parveen Prajapati
Parveen Prajapati

Reputation: 83

Try This:

@Override
    public void onTokenRefresh() {
        super.onTokenRefresh();
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();

        // Saving reg id to shared preferences
        storeRegIdInPref(refreshedToken);

        // sending reg id to your server
        sendRegistrationToServer(refreshedToken);

        // Notify UI that registration has completed, so the progress indicator can be hidden.
        Intent registrationComplete = new Intent(Config.REGISTRATION_COMPLETE);
        registrationComplete.putExtra("token", refreshedToken);
        LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
    }

Upvotes: 0

Sohail
Sohail

Reputation: 1147

Invalid Registration Token 200 + error:InvalidRegistration Check the format of the registration token you pass to the server. Make sure it matches the registration token the client app receives from registering with Firebase Notifications. Do not truncate or add additional characters.

https://firebase.google.com/docs/cloud-messaging/http-server-ref

Upvotes: 0

user6623857
user6623857

Reputation:

Actually I had minimum field length in database for storing instance id so full id would not be saved when I increased field length to 300 it worked

Upvotes: 2

android_jain
android_jain

Reputation: 798

your device id was wrong or you r not using device id as string you have not mentioned which language you r using .i got same issue in php .i got device id using select query and directly asighn to fields .i got same error .but then i converter value as string in php i got successfull result i got notification so check your device id

Upvotes: 0

Related Questions