MismatchSenderId error

1

I had several projects on my console. I was able to receive push notification (PN). So I dropped all the projects and created just one. I made an app based on the step by step that a colleague passed me and I could not receive. I got the App that was working, and put it in the same project that was created in the firebase console. Well, it happens that when I through my PN upload program, when I make a new PN, it gives me error of:

  

MismatchSenderId

The most interesting thing is that when I gave the first start in the application, a PN was sent, but not by me, as if it were stuck and at the start it came, but that was it. Then he did not give any more message, giving that mistake. I am debugging to see what can be and I think it should be the same thing that is preventing me from receiving the PN for this new approach that I am doing.

EDIT1

My Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.global.autorizador.br" android:installLocation="internalOnly" android:versionName="Spike">
    <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="25" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:label="Autorizador.Android" android:icon="@drawable/icon">    

        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" 
              android:exported="false" />
        <receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" 
              android:exported="true" 
              android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="${applicationId}" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

This App was working and getting PN

EDIT2

This is the code for sending PN

public static async Task<IFCMResponse> SenderMessage()
        {
            FCMClient client = new FCMClient("XXXXXXXXXXXXXXXXX"); //as derived from https://console.firebase.google.com/project/
            var message = new Message()
            {
                To = "YYYYYYYYYYYYYYYYYY", //topic example /topics/all
                Notification = new AndroidNotification()
                {
                    Body = "Solicitação de Novo Desconto",
                    Title = "Desconto",
                }
            };
            var result = await client.SendMessageAsync(message);
            return result;
        }

What I can guarantee is that FCMClient is receiving the server key of the current project and Message is receiving the token, at the time the App is started. How I do? I put a break where it is registered, I get this token and lap in the Sender application. And when I send the message, I put a break in return result and there I see the MismatchSenderId error. What might be incorrect would be the firebase project, but I saw the URL and it is OK and inside the project have those values generated by it (project) and I think they are correct as well.

What I found strange is that this piece in google-services.json was like this

"api_key": [
        {
          "current_key": "AIzaSyCHqktEMu9xPGHnXpEXWwRpimBRgzv-MHU" 
        }
      ]

And since the server's web api key was different, I switched to the key that was on the server. This is enough to say that something is wrong, because when we get to the point of changing something automatically generated, it is problem.

"api_key": [
        {
          "current_key": "AIzaSyB2iXNmbPjvwZqDNubYX2Sy6QMsMJmw3N4" 
        }
      ]

I do not know if I did it right, I'm not sure if the key used in current_key is the same web api key

EDIT3

Reading the correlated issues on the internet, I discovered that the SenderID that the application is running is not the same as it is in the project. How does this happen and how do I solve it? This is what the application is loading:

857564901519

and this is the project that is being pointed out by the program that sends the PNs

903763617329

    
asked by anonymous 01.10.2017 / 21:40

1 answer

0

The problem is that the SenderID is a constant. As before it was set for a project, it was bringing the previous SenderID value. I set it to the current value and it is ok. I've looked at this whole code except constants. Of course, a little failure of mine.

    
03.10.2017 / 12:28