I have built an application with flutter that works like a reminder.
How can I display notifications to the user even though the app is closed?
相关问题
- Plugin with id 'com.google.gms.google-services
- google-drive can't get push notifications
- Flutter : Prepare list data from http request
- How to schedule an alarm on specific time in Flutt
- MappedListIterable is not a SubType
相关文章
- Observatory server failed to start - Fails to crea
- Flutter error retrieving device properties for ro.
- How can I add media attachments to my push notific
- Adding Shadows at the bottom of a container in flu
- Flutter. Check if a file exists before loading it
- Flutter - http.get fails on macos build target: Co
- How to convert a FCM token to APNS token?
- How to open current activity which is open while c
For reminders i would recomend Flutter Local Notifications Plugin. It has a powerful scheduling api. From the documentation of local notification:
And for push notification, you can use Firebase Cloud Messaging or one signal plugin or you can implement natively through platform-channels
Edit: You can also fire notifications according to specific conditions even if the app is terminated. This can be achevied by running dart code in the background. Quoting from the official faq:
I have also faced this issue, So these are my learnings
In my Case : i am able to get notification in App-Resume or App-background state, but in App-Close state, I am not receiving notifification.
In this case our notification body was :
To Receive Notification in App-Closed state we changed notification to
You can use scheduled notifications in flutter.
I have found a solution to this problem. We just have to register the Local Notification Plugin in the Application class.
First Create a class FlutterLocalNotificationPluginRegistrant, I have created this in Kotlin.
Now create a Application class extending FlutterApplication and implement PluginRegistry.PluginRegistrantCallback.
and register the Application class in the AndroidManifest.xml
All done. Now write a function to show notification and call it from the background handler method of Firebase messaging.
and call it like this.
The official firebase_messaging flutter plugin supports showing notification sent via FCM. Recently in v5.1.5 they added support for background message handling for andriod.
https://pub.dev/packages/firebase_messaging#515