I'm developing an android app using flutter which uses Firebase cloud messaging.
Everything was working fine and it was receiving cloud messages but recently nothing happens when the device receives a cloud message no matter the app is in foreground or background or terminated.
The only thing that is logged into console is:
E/FlutterFcmService: Fatal: failed to find callback
which from what I know it belongs to the fact that I haven't handled background messages and despite this I should be able to receive the message.
how can I realize what is the cause of this problem? a log file or something?
PS:
I've tested on real devices with Android version 21 and 29 and the results are the same.
PS:
I've done
flutter pub upgrade
flutter pub get
flutter clean
and removed the app entirely then installed it again.
PS: I've sent the message using Firebase console and the project backend. both include 'notification' field inside the message.
Thanks in advance
Related
I have a Flutter app registered with Firebase for both iOS and Android. The FCM (push notifications) is meant to work for Android as per https://firebase.flutter.dev/docs/messaging/overview/ pretty much out-of-the-box.
Alas, it doesn't.
I added it to pubspec.yaml. I actually added firebase_messaging: ^7.0.3 because anything newer breaks other dependencies. Then I go to Firebase console and send a test message targeted at my Android registered app. Once the message goes through and it says it is Completed no message comes to my simulator.
I know FCM on iOS has an issue with simulator but I have not read anything about it being a case on Android.
I added import 'package:firebase_messaging/firebase_messaging.dart'; and instantiated FirebaseMessaging messaging = FirebaseMessaging(); both in main and results are as above i.e. nothing comes through to my simulator's notifications.
The strangest thing is that I originally followed https://sebastianengel.medium.com/easy-push-notifications-with-flutter-and-firebase-cloud-messaging-d96084f5954f which is substantially more involved and I did get first notification(sic!) but not any subsequent ones. I tried to do this solution from ground up again but the notifications on my simulator remained indifferent.
One thing to bear in mind is that I use few other Firebase services so I know my app is correctly registered with Firebase... unless there's some additional step that I missed and can't see.
Anyone please went through the same ordeal and can pinpoint my blindspot? Thank you.
UPDATE -
I checked error logs and they are empty.
Could you post some more information? For example the console log when you send a notification (try troubleshooting with basic print statements also), better still, send a reproducible snippet of code so I can recreate your problem.
Also make sure you initialize notification handling at a top level function (main preferably).
I'd be happy to work with you, reach me on seanonuoha#gmail.com, when we fix the problem, you post the results here.
Cheers
If you follow the steps in this documentation and still got no message or notification you can check your emulator settings.
Emulator stands default SERIAL CONSOLE DISABLED.
Slide it and turn it to enabled.
My problem solved with this issue.
If you tried and still get problem. Do not hesitate to ask again.
....
I faced a problem that my app can't connect to firebase any more I just deleted my app from firebase project and added it to another project, after that my application can't connect to firebase and I have this message loading
Checking if the app has communicated with our servers. You may need to uninstall and reinstall your app.
and when I try to send FCM notification it not send I have this error message
"error": "MismatchSenderId"
Your app must communicate first with your Firebase project before you start sending any FCM notifications and start using other services.
I recommend you to read this documentation:
https://firebase.google.com/docs/android/setup?authuser=0
Make sure that you enter the package name that your app is actually using. You cannot add or modify this value after you register your app with your Firebase project.
And please make sure that you deleted old google-services.json file from your app directory and replaced it with the new one. You can find documentation on this here: https://support.google.com/firebase/answer/7015592?authuser=0
After all these changes, it is recommended that you uninstall your app from the emulator/physical device first, then install it again. Open it a few times, wait for a few minutes and the app should be connected to your firebase project.
I had the exact problem. Google JSON was fine, had uninstalled the app and updated the fcm server key but it didn't work.
In the end, all I did was to:
-uninstall the app again
-restart my device
-clean project
-invalidate caches and restart
and it started working.
In JS, using firebase.messaging().getToken();, I'm able to successfully get an FCM token.
I'm going into our project in Firebase and sending a test notification to this device.
The notification does not appear on my device.
So:
1.I'm able to generate an FCM token and correctly access it
2.No errors in Android Studio or during the build
3.No errors in my JS console
4.I'm not able to RECEIVE the push notification. Nothing happens. I've tried looking in the logs in android studio, but I'm not seeing anything (and the logs seem to stop running when my app is closed/in the background)
I am working on pushnotifications w.r.t. bluemix services recently, for cordova android application.
Toolkits used: Android 24 version, Java 8.
Steps followed: once user registered with bluemix services for push notifications w.r.t. GCM (google cloud messaging), then send push notification from the bluemix console service. Unfortunately I didn't get any of the notifications to the android device.
NOTE: I have followed steps provided from the below url:
https://github.com/ibm-bluemix-mobile-services/bms-samples-cordova-hellopush
So I've just attempted to recreate your issue and ran through the sample with the latest version of Cordova (6.3.1). I'm also running the newest version of Android Studio:
There was some lag when initially sending my Push notifications (it probably took ~5-10 minutes after initial registration for me before they all started to come through).
Before sending:
After sent:
From your issues, on the top of my head, I think of a few things that could have potentially gone wrong:
There was some network latency after registration, and the Push Notifications would have eventually come through.
Your GCM / Push Notifications service was configured incorrectly. To test this, I would try out the Android hellopush sample to see if I can get anything.
Different versions of Cordova or the emulator could be the culprit.
It could be something else entirely :0)
If you keep running into issues or #4 is the case, I recommend opening up a support ticket with your Push Notifications service instance. This should provide a little more of your app information to the Bluemix Mobile service team, and they should be able to look at the server logs to see what is happening to your notifications.
i am not receiving notification after sending it through firebase console , i tried sending many notification but received one or two from around 20 notifications, i followed this guide firebase messaging from github
,why am i not receiving notification, my app is installed in one emulator and in one of my phone but when i receive notification which i have sent through notification panel i get them either on phone or emulator never got them on both.
below is the screenshot of my console
check your android app configuration in firebase console
use a restful client to make the request, i suggest
chrome-extension://aejoelaoggembcahagimdiliamlcdmfm/dhc.html,
there you can see the response of the request, if your request are sent sucessfully or if you have error, and the response tells what kind of error you have
check android app , in the method onMessageReceived and print everything to see if you receive information, besides you can print the property "from" who is the id_number of your proyect, and you can see if the messages come from your firebase android app
check firebase documentation.
I've implemented everything just with the guides and its working pretty well
I solved the same problem.
The problem seems to be the browser compatibility/version. Mozilla Firefox could easily handle this.
Make sure your app is running in the background.
Open the Firebase notification console in the FireFox browser and send notifications.
Make sure token is generated
FirebaseInstanceId.getInstance().getToken();
in my case, the package name defined at firebase console isn't the same as defined on gradle and manifest of the app (i changed it one time in the app), so the app won't be able to receive notifications sent from firebase console.
They both have to be the same!
I did not add a new firebase project, just go to project settings at console and add new android app with another package name and have a look at the newly generated google-services.json and change some lines at you android studio project.
Besides the tips that Pavul Zavala said ، keep this in mind that just data message can received by FirebaseMessagingService even application closed or run in background and notification message can't handle(till this moment) when application run in background.
And all message that sent via FireBase console Contains , they always include a notification key
more detail at :
Push notification works incorrectly when app is on background or not running
In my case, what helped me is creating a new simulator in Android Studio
Few things to check:
in Firebase console https://console.firebase.google.com/ add/configure the project
in Android Studio connect to Firebase - Manu -> Tolls -> Firebase -> Cloud Messaging (Connect, Add FCM to your app)
Send notification from Firebase console
So, again, I recreated Virtual Device (open AVD manger and create the same device with the same API level)
I will be happy if somebody will save the time using this post :)
Ideally it shouldn't behave like that but it might be due to following reasons:
Check the notification priority of your app in the app settings of the device.
You might be sending the token of one particular device, Your target should be User segment.