FCM getting MismatchSenderId

前端 未结 29 1891
刺人心
刺人心 2020-12-04 17:34

I have an application that uses Google FCM for sending push notifications.

When i send a push notification to a group of users, i get a response of MismatchSen

相关标签:
29条回答
  • 2020-12-04 17:51

    check gcm_sender_id in manifest.json If mismatch - correct, but you need make new subscribers for new sender Id. Exists subscribers break.

    0 讨论(0)
  • 2020-12-04 17:51

    your probably doing whwat i was doing. GCM token is not the same as FCM anymore. check if your pulling the GCM token ID instead of FCM. just override FirebaseInstanceIdService & ensure your getting the right ID. i thought at one point they were the same but now there not. i logged a test and saw. after you do that also update google-services.json like others say as a safety.

    0 讨论(0)
  • 2020-12-04 17:53
    • I cross verified all the credentials

    • Added new server key and deleted old one

    • Downloaded google-services.json again

    Nothing solved the issue

    Then I just clean the project and then rebuild the project.After that it's working fine

    0 讨论(0)
  • 2020-12-04 17:54

    THIS WORKED FOR ME:

    • CHECK WHICH FIREBASE PROJECT YOUR CURRENT ANDROID PROJECT IS LINKED TO AND USE Server Key FROM THAT PROJECT.

    I was using Server key from a different firebase project(say Project 2). I used the same server key as linked with my android project(Say Project 1) and it worked. In my experience, using one firebase app for one entire android project seemed to fix the problem.

    0 讨论(0)
  • 2020-12-04 17:54

    I had big trouble figuring out why I was getting a "MismatchSenderId" status. I added the gms dependency in the root build.gradle but my error was actually not applying the gms plugin in the app build.gradle.

    If you have don't have this line in the app build.gradle, this could be the reason why the notification are not working: apply plugin: 'com.google.gms.google-services'

    0 讨论(0)
  • 2020-12-04 17:57

    I had the same issue in my react-native - node.js project. I wanted to send notifications in android. Everything was set-up and working fine (i.e. I was able to send notifications from node.js and receive notifications on android device).

    After a few days, I had to use a different firebase account, so I changed the google-services.json file in my project's android/app folder and rebuilt the project. But, when I tried sending notification from my server once again, I got an error -

    {.............
      errorInfo: {
        code: 'messaging/mismatched-credential',
        message: 'SenderId mismatch'
      },
      codePrefix: 'messaging'
    }
    

    Solution:

    the XML file at the location - app/build/generated/res/google-services/{build_type}/values/values.xml was not getting automatically updated according to new google-services.json. It still consisted of old values from my previous google-services.json file. I had to change values.xml file manually.

    This is how app/build/generated/res/google-services/{build_type}/values/values.xml file look (You need to change it manually if it does not get updated automatically according to google-services.json)-

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <! -- Present in all applications -->
        <string name="google_app_id" translatable="false">1:1035469437089:android:73a4fb8297b2cd4f</string>
    
        <! -- Present in applications with the appropriate services configured -->
        <string name="gcm_defaultSenderId" translatable="false">1035469437089</string>
        <string name="default_web_client_id" translatable="false">337894902146-e4uksm38sne0bqrj6uvkbo4oiu4hvigl.apps.googleusercontent.com</string>
        <string name="ga_trackingId" translatable="false">UA-65557217-3</string>
        <string name="firebase_database_url" translatable="false">https://example-url.firebaseio.com</string>
        <string name="google_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string>
        <string name="google_crash_reporting_api_key" translatable="false">AIzbSyCILMsOuUKwN3qhtxrPq7FFemDJUAXTyZ8</string>
        <string name="project_id" translatable="false">mydemoapp</string>
    
    </resources> 
    

    You can refer to these links:

    1. https://firebase.google.com/docs/projects/multiprojects
    2. Processing the JSON file: https://developers.google.com/android/guides/google-services-plugin#processing_the_json_file.
    0 讨论(0)
提交回复
热议问题