thingsboard / dart_thingsboard_client

ThingsBoard API client library for Dart developers.
BSD 3-Clause "New" or "Revised" License
59 stars 30 forks source link

Failed to send message via FCM: SenderId mismatch #31

Closed mahshadparsa closed 2 months ago

mahshadparsa commented 4 months ago

hello everyone. I am trying to send a notification from ThingsBoard to my custom Flutter app. I Generated a project in FireBase and I set the key of ThingsBoard like the following link: https://thingsboard.io/docs/pe/mobile/getting-started/ I use thingsboard_client: ^1.1.1 in my custom Flutter app, and I set FireBase in my app according to the following link: https://firebase.google.com/docs/flutter/setup?hl=en&authuser=0&platform=android Now, I can receive notifications from the FireBase console, But not ThingsBoard! when I send a notification from thingsBoard, I get "Failed to send message via FCM: SenderId mismatch" error. 2

Please, let me know, how I can fix this problem.

I am using thingsboard 3.6.3, and flutter 3.19.4.

ybeshkarov commented 4 months ago

Hello @mahshadparsa.

Please ensure that you are using the same Firebase for both your mobile app and the backend. If you are using the Firebase CLI script, make sure you have selected the correct Firebase project during the configuration of your mobile app (Step 4.2).

mahshadparsa commented 4 months ago

Hello @ybeshkarov I have just one project in my FireBase, and I used the key of that project for ThingsBoard and the google-service.json of that project for my custom Flutter app. But I can not get a notification yet.

ybeshkarov commented 4 months ago

Hello @mahshadparsa,

I encountered the same issue when my TB backend instance was using a key from a different Firebase than my mobile app. You might want to regenerate your Firebase Admin SDK key by following this guide (Step 4.1). Afterward, add this key as a sysadmin to your TB backend instance. Finally, confirm with the Firebase CLI that your mobile app uses the same Firebase.

mahshadparsa commented 4 months ago

Hello @ybeshkarov, Thanks for your response. I have just one project in the Firebase. I regenerated the Firebase Admin SDK key and added it to my TB backend instance as a sysadmin. I checked the Firebase CLI, and my mobile app uses the same Firebase. But I still have that problem.

ViacheslavKlimov commented 4 months ago

Hi @mahshadparsa,

Please do the following:

If it didn't help, you might also try to restart ThingsBoard.

mahshadparsa commented 4 months ago

Hello @ViacheslavKlimov I checked the Firebase and Firebase Cloud Messaging API is enable. Please let me know, how can I do a clean rebuild of my custom app in android studio? About restarting TingsBoard I reinstalled it 3 weeks ago.

ybeshkarov commented 4 months ago

Hello @mahshadparsa, To perform a clean rebuild of your custom app in Android Studio, follow these steps:

  1. In your application's root path, run flutter clean.
  2. In the same location, run flutterfire configure.
  3. Finally, run flutter run. If you want to build a release version, use flutter run --release.
mahshadparsa commented 4 months ago

Based on the steps mentioned, I performed a clean rebuild of my custom app in Android Studio. But I just can receive a notification from the Firebase console, not from the Thingsbaord. In the Thingsboard, I receive the error "User doesn't use the mobile app"!

ybeshkarov commented 4 months ago

@mahshadparsa, please try logging out and back into your mobile app.

mahshadparsa commented 4 months ago

I logged out of the mobile app and logged in again and I received the error "User doesn't use the mobile app" again! I restarted the Thingsboard again and it doesn't have any effect.

ybeshkarov commented 4 months ago

@mahshadparsa, could you open an issue at: https://github.com/thingsboard/thingsboard/issues? It's related to the backend, not mobile.

mahshadparsa commented 4 months ago

Thank you @ybeshkarov I opened this issue at: https://github.com/thingsboard/thingsboard/issues https://github.com/thingsboard/thingsboard/issues/10602