MaikuB / flutter_local_notifications

A Flutter plugin for displaying local notifications on Android, iOS, macOS and Linux
2.43k stars 1.38k forks source link

iOS when background headless FlutterEngine is running onDidReceiveBackgroundNotificationResponse gets paused and resumes when app comes to foreground #1932

Open adar2378 opened 1 year ago

adar2378 commented 1 year ago

Describe the bug Thank you for the package. We are using firebase_messaging along with flutter_local_notification. One big problem we are facing right now is on iOS when the app is terminated and firebase_messaging's onBackgroundMessage callback gets triggered I see that it also triggers the main method. And a FlutterEngine runs I believe. After that when we press on notification action, then the onDidReceiveBackgroundNotificationResponse gets triggered and it runs until there is an API call, and the API calls get postponed after being getting called. And it resumes again via manually opening the app but at the time the API calls are getting timed out because there is no guarantee when the user will open the app. Is there any possibility that there is some FlutterEngine conflict?

The related issue with firebase_message : https://github.com/firebase/flutterfire/issues/7407

myselfuser1 commented 1 year ago

This will help https://www.youtube.com/watch?v=aQTvI8L-mZs

adar2378 commented 1 year ago

@MaikuB Any thoughts on this please?

MaikuB commented 1 year ago

I don't have the capacity to look further into this in great depth so if best bet is you help look into this, similar to how support for notification actions was a contribution from other developers in the community as well. From what you linked it sounds like a potential issue with Flutter. The issue linked talks about main() being executed as well, which personally I wouldn't expect from how that documented background isolates to work before. I don't see the relationship between that and your issue but perhaps you could elaborate more on what the relationship is in case I'm missing something. I've read before that these background isolates should only be used for short work though I don't have links/references to where I read this. If this is true, perhaps this is what you're running into