2

FCM push is working fine in Signed APK but when I am using the same server key and JSON in the debug version, the FCM is showing mismatch sender id. I have already added the SHA 1 in the firebase console and also tried with the legacy key but still getting the mismatch sender id error. Package name, google service JSON and the notification everything is the same for both cases but it's working only in the signed APK. How can I solve this issue?

this is my notification JSON

{"collapse_key":"axxxpex","data":{"match_id":7,"sound":"default","title":"test","body":"Goal....","android_channel_id":"channelone"},"to":"f8Yf3AxxxxxxxxxxxxEFXUrcKLxzRfyzfw-J5xxxxxxxxFCC","priority":"high","ttl":"86400s"}
MarGin
  • 2,078
  • 1
  • 17
  • 28
  • Is you SHA1 is different for debug and release build? – Md. Asaduzzaman Nov 18 '19 at 09:24
  • That means you did not register to Firebase properly in Debug mode. Actually, you don't need to register sha signature to get FCM working. SHA is required for some other services, like Google Login – user1209216 Nov 18 '19 at 09:25
  • @Md.Asaduzzaman SHA 1 is the same for debugging and production – MarGin Nov 18 '19 at 09:28
  • @user1209216 how can I properly register firebase in debug mode. Firebase is already initialized in the application class – MarGin Nov 18 '19 at 09:30
  • I use in debug and release mode and I have no problems. Code is the same. Are you sure you are registering properly? – user1209216 Nov 18 '19 at 09:30
  • @user1209216 yes I am getting the push token correctly. but when I am using the push URI am getting the mismatch sender id – MarGin Nov 18 '19 at 09:32
  • Is package name the same in debug/release modes? – user1209216 Nov 18 '19 at 09:33
  • @user1209216 yes – MarGin Nov 18 '19 at 09:33
  • Show your code to send message? I don't understand, in my case I have only single json payload and both debug/release variants are able to receive the same push. Server key is the same for debug and for release variant too – user1209216 Nov 18 '19 at 09:35
  • the message and the structure are the same in both cases. – MarGin Nov 18 '19 at 09:36
  • So what is different? There is nothing needs to be different afaik – user1209216 Nov 18 '19 at 09:36
  • the only difference is the one that working is signed – MarGin Nov 18 '19 at 09:38
  • Do you put json to server and you are getting error reponse? Where is error thrown? Inside app or on server that sends json payload? – user1209216 Nov 18 '19 at 09:40
  • @user1209216 not in the app from the server-side. I have even tried from the postman { "multicast_id": 8662261872491105633, "success": 0, "failure": 1, "canonical_ids": 0, "results": [ { "error": "MismatchSenderId" } ] } . this is the error – MarGin Nov 18 '19 at 09:43
  • Are the package name's the same for debug and prod? if not this is could be the problem. – The Dude Nov 18 '19 at 09:44
  • @TheDude package name is same – MarGin Nov 18 '19 at 09:44
  • Show your json you put to Google, update your question – user1209216 Nov 18 '19 at 09:44
  • @user1209216 you mean the notification JSON ? – MarGin Nov 18 '19 at 09:49
  • Yes, that should be the same json with the same keys and app should receive push, it does not matter you compile it in debug or release mode. APK signature does not matter. There should be no error reponse, unless you unregister your app. – user1209216 Nov 18 '19 at 10:16
  • @user1209216 the JSON is the same in both cases. I updated the question – MarGin Nov 18 '19 at 10:23
  • As you are sending the same json all the time, what you need to do to make your post returning error message? It starts returing error after you run your app in debug mode? – user1209216 Nov 18 '19 at 10:40

2 Answers2

1

Just use FCM OWNER account to send the notification on debug APK

0

Try to add signing configs for debug APK, generate SHA 1 for it and add it to firebase console

Nazarii Moshenskiy
  • 1,802
  • 2
  • 16
  • 35