-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[firebase_messaging] Crash when set onBackgroundMessage #125
Comments
I'm having the same issue. |
Any updates on this issue? |
I'm having the same issue |
I'm having a related issue here: |
Yup its definitely crashing |
+1, crashing for me as well |
+1 For me as well |
Same issue [✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.15 19A583, locale en-GB) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • No issues found! |
is this ever going to get fixed? |
+1, Same issue |
I have the same issue, but when i switch flutter channel to beta ( according to this: #144) then there's no crash anymore |
Same issue here |
same |
same |
got same issue.. |
same problem here |
same problem. It's critical bug. |
Guys, did you try call the messaging on top of you'r app? I tried like this and it works for me ( so far. ) Both in dev mode and in release mode works fine now.
|
this Doesn't work for me. |
Nor does this work for me. Though my problem is with iOS #1469. I've seen it mentioned as a solution in another issue, and it has a few likes #144 (comment). It may very well fix the problem in Android devices, but not in iOS. |
@Eddydpyl I have set
and it works perfectly fine. I receive notifications when app is in background , terminated, or in foreground. |
@DyaryRaoof how do I handle data messages in iOS then? I don't want the notification, just the data payload, which is why I'm setting onBackgroundMessage instead of onMessage, onLaunch or onResume. |
@Eddydpyl You get the payload as part of the message variable that you have setup when you configured fireBase.
print the |
@DyaryRaoof I do, but I failed to mention that I need that data in the background. On Android, using onBackgroundMessage I'm able to process said data wether the app is in the foreground or not, but on iOS the onMessage callback only triggers after I reopen the app. |
@Eddydpyl can you please tell how are you able to get messages in background on Android.? My app is crashing at startup with background message handler set. I am even configuring it as a top level function. Where are you configuring it. Can you help please? |
@naumanmir I wish... I'm not doing anything special, and I haven't actually tested it on any of the phone models that people are reporting it's not working on. Furthermore, there's this issue that popped up (#1709). You can find some more details on how I'm doing things there, but again, it's nothing special. About iOS, I never got it to work, though I assume that it has more to do with a limitation of the OS than a bug on this library's part. |
Hi @festelo It seems people are still experiencing this crash. Have you tried the same code on a different virtual device? I attempted to reproduce this with a Pixel 3 API 28, But, I wasn't able to get it to crash when adding the I'm also assuming that you were able to receive messages in the foreground with the |
yes the crash is still there even with applying the classpath and using Pixel 3 API 28 Emulator. |
Hey everyone, did anybody figure out a solution for this? App crashes as soon as notification is received when onBackgroundMessage is enabled. Without it everything works fine. But then this means that I can't process notifications when app is terminated. I can just run code onLaunch. Which beats the purpose of onBackgroundMessage. Is it just not working ? |
no nothing up to now |
seemed like flutter framework bug |
Followed official tutorial with up-to-date everything. Issue is still present - I receive notifications properly and everything but onBackgroundMessage is working |
Guys, even after so many upvotes and frustrations nobody from the team is taking this seriously, I really don't understand how two Google products have so much incompatibility. It was so much smoother to configure Push Notifications with React native than it has been for Flutter. The Documentation is completely outdated, there is not mention of Kotlin related changes anywhere. And even if you somehow manage to get it working as soon as you add the onBackroundMessage function the App crashes with absolutely no error. I am on OnePlus 5T device. Please give some kind of conclusion or assurance or solution. Something. It's been a week almost since I have been trying this. This should be a very straightforward configuration IMO. It's not even an edge case. Everyone is going to need Background messaging at some point in their Application Development Cycle. |
First and foremost I would like to say that I agree with @sakina1403 . It drives crazy how something as important as notification can be so messy and frustrating. I managed, somehow, to make firebase_massage work. It's not the best solution (and really verbose) but I'll share it as it can solve someone's problem. Assuming that firebase cloud with the basic notification is working (onMessage, onLaunch, onResume), and that I work on 1.18.0-9.0.pre.38 (master), I'll try to focus on onBackgroundMessage (which caused me more headaches). Also, I used flutter_local_notification to display messages (also needed some plugin registration to make it work). As in all comments reported, 'onBackgroundMessage' needs a static function to work (or top level). In my case, I implemented 'myBackgroundMessageHandler'. FirebaseMessaging configure:
Not much mystery so far. But that part was what made everything stop working. In 'android/app/src/main/java/' (where are folders I created, eg com/example/my_notification_test, - same path that appears in AndroidManifest.xml at 'package') After creating these folders I created 3 files: 'Application.java', 'FirebaseCloudMessagingPluginRegistrant.java', and 'FlutterLocalNotificationPluginRegistrant.java'.
In AndroidManifest.xml I changed android:name to ".Application":
And I've added permission on top of the tag <application. More like this:
Finally my _showNotification(...) function:
The code is not organized, but this is more or less what I did to work. I hope I've helped |
@drikanius your solution made it not crash anymore for me! |
Could solve it (at least for android) now with
So for me, notifications also work when the app is closed now |
@joshipucher good to know it's working. I probably forgot to mention the permission part (sorry =/). |
I concur with @sakina1403 this is an embarassment to Flutter trying to get push notifications working (well @drikanius trying to follow your instructions but getting
Update: Nevermind, configured it incorrectly as changed activity.android.name instead of application.name. |
Hey all 👋 As part of our roadmap (#2582) we've just shipped a complete rework of the If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here. Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin. Thanks everyone 🤓 |
The following code causes immediate crash after app launching:
If myBackgroundMessageHandler method isn't on top level, then it's not crashing, but throws null exception ("'toRawHandle' was called on null")
Without
onBackgroundMessage: myBackgroundMessageHandler,
all works fine.Application.java class:
compileSdkVersion - 28
google-services version - 4.3.0
Crash log:
On Xiaomi Mi 9 (9.0.0) & Genymotion virtual device (7.1.0) (gservices installed)
The text was updated successfully, but these errors were encountered: