MismatchSenderId를받는 FCM
푸시 알림을 보내기 위해 Google FCM을 사용하는 애플리케이션이 있습니다.
사용자 그룹에 푸시 알림을 보낼 때 MismatchSenderId
일부 사용자에 대한 응답을받습니다 . 그러나 모든 사용자는 똑같은 응용 프로그램을 사용합니다. 일부 사용자는 어떻게 성공 응답을 받고 다른 사용자는 MismatchSenderId를 얻을 수 있습니까?
나는 많이 조사했고 FCM에 필요한 모든 전제 조건을 추가했는지 확인했습니다.
어떤 제안?
편집하다:
샘플 응답 :
{"multicast_id":5340432438815499122,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
편집 2 :
다음은 서버 측 전송 코드 (PHP)입니다.
$fields = array
(
'to' => $token,
'data' => $data
);
$headers = array
(
'Authorization: key=AIza**************************',
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, true );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode($fields) );
curl_exec( $ch );
curl_close( $ch );
최신 정보:
SDK 업데이트로 문제가 해결 된 것 같습니다. 현재 최신을 사용하고 있습니다 com.google.firebase:firebase-messaging:9.6.1
. "MismatchSenderId"가 더 이상 표시되지 않습니다.
Firebase는 서버 키를 새 버전으로 업그레이드했습니다. 이전 키 대신 새 키를 사용하십시오.
설정-> 프로젝트 설정-> 클라우드 메시징 탭으로 이동하십시오.
Maybe it will work
I had the same problem. After hours spending to figure it out, I found this solution:
- First I check server key is correct or not it was correct which is like AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Then I check Sender Id like 79XXXXXXXX it was also correct.
- Main issue was in device_ID(UDID) to whom I have to send the notification. Actually DeviceId we got on android side in FCM is different than GCM. You can't use GCM created DeviceId in FCM.
Hope this will help you. Thanks
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.
In my case, I just was mistaking about project credentials: using google-services.json from one project, and server key from another.
what works for me :
I found that the senderId is different from the project number in the FCM console
so I re-downloaded google-services.json and everything works fine
Make sure you remove all the Parse code from your app (libraries, receivers in AndroidManifest, etc). I found that intermittently push notifications were not working. From my observations, it would work on fresh installs but not app updates from the play store.
I believe something internal to Parse was conflicting with FCM (Parse uses GCM, so I'm guessing it had to do with using GCM and FCM simultaneously). As soon as I ripped out all the Parse receivers and libraries, things worked great.
We spent hours and hours to resolve this issue. What we found that token was being generated using different FCM account settings (google-services.json) and notification was being set using different FCM account. When we synced both it worked like a charm.
check gcm_sender_id in manifest.json If mismatch - correct, but you need make new subscribers for new sender Id. Exists subscribers break.
As per response "MismatchSenderId", this is a mismatch between FireBase and your local "google-services.json", you have to make sure that both manifests matches
In FireBase console you go to "YourProject > Project OverView > Cloud Messaging" you'll see the "SenderID" which MUST match with the "google-services.json" in your Android project.
Best thing you can do is download the final json file from "General" tab and place it in your project.
I had the same error while trying to send push notificaion. Get the updated google-services.json file and replaced with it. Worked for me.
Actually there are many reasons for this issue. Mine was because of Invalid token passed. I was passing same token generated from one app and using same token in another app. Once token updated , it work for me.
Just an FYI. I was running into this error, even though I swear the android app I was testing was built with the latest/greatest google-services.json file and I could send from the FCM console to the app. I rebuilt the app after doing a Clean Project
and now I can send to the app with the FCM token it registers. So, maybe try a clean rebuild before beating your head against the wall for too long.
I had the same problem, and I fixed it like this:
- Go to your google fcm console
- Select your app
- In the left side menu find settings icon (standard wheel)
- Click on it and after click on project settings
- Now copy your server key and paste it in php
Voila...
Updating firebase initialization works for me..
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script>
// Initialize Firebase
// TODO: Replace with your project's customized code snippet
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
</script>
For me the problem was that I was using the phonegap-plugin-push
in cordova, testing the app with the phonegap app.
The problem with this is that for some reason with this plugin, the phonegap app intercepts it and returns a dummy registration key, no matter what sender ID you have.
So to make it work (as long as you have all your keys right) is to test your program some other way, with an emulator, or android emulation via usb. And your keys will match.
Hopefully this saves someone some time.
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.
Hello i have noticed that when an device id is created in GCM you cannot send push messages through FCM using the new server key, you have to use the old API-key.
I wasted days on this.
In my case, I followed this blog to use Postman and get the mismatchsenderid error. Previously, I was getting messaging/mismatched-credential
, and people reported that their client app used multiple projects.
However, for me, I have one-to-one, a web app and a project. BUT, I host all apps via ng serve
on default port 4200. So regardless of what project / app pair I was developing on, I would always get the same token from my client web app using AngularFireMessaging.requestToken
- this token was always the token created on my first ever run of a firebase app in development.
As a work around, I start different apps / projects on different ports and get proper tokens for respective projects.
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'
Maybe this can help someone Cheers
Note: I had truncated the first part of the FCM token (before :
) and the error was MismatchSenderId
Fixed my script and now everything works fine.
I also getting the same error. i have copied the api_key and change into google_services.json. after that it workig for me
"api_key": [
{
"current_key": "********************"
}
],
try this
firebase console console.firebase.google.com/project/project-XXXXXXXXXXXXX/settings/cloudmessaging 의 설정 섹션 에서 사용할 수있는 AIzaSyDiTEVq4Li1pj7IyraRlyRU9adc-49-KVY 와 같은 서버 키가 있습니다 .
코드와 함께 올바른 키 를 지정하고 다시 시도하십시오.
참고 URL : https://stackoverflow.com/questions/37863106/fcm-getting-mismatchsenderid
'Programing' 카테고리의 다른 글
Interlocked.Exchange가 부울 유형을 지원하지 않는 이유는 무엇입니까? (0) | 2020.12.02 |
---|---|
Datomic은 언제 사용해야합니까? (0) | 2020.12.02 |
WPF XAML StringFormat DateTime : 잘못된 문화권의 출력? (0) | 2020.12.02 |
PHP 이미지 업로드 보안 검사 목록 (0) | 2020.12.02 |
Android : 버튼 텍스트 및 배경색 변경 (0) | 2020.12.01 |