I want it to appear in the background service I wrote when I receive notifications from any application with Flutter or native Android.
I looked at different solutions made before, but it didn't work out exactly what I wanted.
What is the best way to do this?
flutter local notification package :- https://pub.dev/packages/flutter_local_notifications
Example of onDidReceiveNotificationResponse
https://i.stack.imgur.com/ihhR6.png
Use flutter_local_notification and write your code in onDidReceiveNotificationResponse property.
Related
I just finished my first Android Studio App with Kotlin. The Design/UI of the App is pretty lame, but works fine. Now I want to "upgrade" my UI with replacing/adding new Components that look better. I started reading about Flutter, but I only see tutorials where they start a complete new app from scratch. Since I got a working app, how can I simply only use the "design"-Options of flutter and let my source code be?
Im pretty new in this field, but got some C#-Experience but never did an App and since this is my diploma thesis, I just want to use all my resources so the App also looks professional in terms of UI-Design etc.
You can add flutter to existing android or ios app you can read here more.
how can I simply only use the "design"-Options of flutter and let my source code be?
Vanilla Android uses XML, however as you are likely aware thats not how it works in flutter. Since the system is completely different, I wouldn't expect you can just "change look" without re-designing it entirely with flutter.
If wanted to use flutter, I would assume you would need to add it incrementally (as mentioned in Gizmo1337's answer).
However if all you want is to update how your app looks, theres nothing stopping you from changing your existing XML style. I'd say it's probably pretty overkill to change to flutter if all you want is a new look.
So I am trying to update contacts upon change notification. I was unable to find any flutter plugins that did so(If you do know any plugins that does so please let me know!! ). I decided to implement the notifications and send a call to do a functionfrom native to flutter. How do you do that? I am really confused.
So, I found this really nice plugin recently. It was hidden when I was searching for it.
https://github.com/Ben-Baert/flutter_listentocontacts
Good Luck,
Ronny McNamara
I am new to Flutter. Can anyone post the link or code for "android foreground service example with a notification"? I googled but didn't get any good example of foreground service.
I'm working on a project that includes an SMS package. This App has to be active on the foreground.
Update:
I have created my own implementation of android foreground service for Flutter called android_long_task. check it out it solved my problem. let me know if it solves your problem by raising an issue.I created my own library because the tutorial I mentioned just shows how to create a foreground service in java and that's all and as you have found out by now the other foregorund_service plugins have some problems.
Old answer (didn't help me):
if you're having a problem with this and none of the libraries mentioned in other answers worked for you. you might wanna give this tutorial from RetroPortal Studio a try. it's a total of 26 minutes which teaches you how to write a working foreground service for flutter android
I tried flutter_foreground_service but it has a big problem. When app closes this plugin throwing error. This bug is reported in here: https://github.com/pauldemarco/foreground_service/issues/1
foreground_service has problem too: https://github.com/pauldemarco/foreground_service/issues/1
Probably there isn't a good solution for now (Jan 2020). If someone develops a good solution may be I add it to here.
I think Google should find solution for this kind of problems. We're using flutter becouse we're thinking that flutter is more effective. If we lost our time kind of this absurd errors why we using flutter? Using kotlin for android, swift for ios this is more good probably.
Pauldemarco has created some excellent flutter packages for flutter. He has developed one for Foreground service too. As of now, it is only supported in android. It is not supported for iOS. I hope this helps.
https://github.com/pauldemarco/foreground_service
You can use library flutter_foreground_task for long or always running task.
I have implemented the PushPlugin for Android and iOS, and most things are working fine.
On iOS everything is perfect. ON Android with the app in the foreground too.
But I have a problem on Android when my app is in the background (or cold-started), and there are multiple notifications queued in the Android status bar. No matter which notification the user taps, the app always gets the top one in the list sent to it.
This is kind of similar to this issue (even if it is not using Cordova/PushPlugin), but I have checked the source code of the plugin, and it is using the PendingIntent.FLAG_UPDATE_CURRENT flag as per that issues solution, but the problem persists for me.
If anyone has succeeded in getting this to run I would be grateful for any tips!
So... It seems the problem is caused by a bug in the PushPlugin.
As described in the Android documentation, multiple PendingIntents needs to have something separating them from each other, otherwise they are all treated as the same.
There is already a pull request on the plugin fixing this, which uses the notId parameter as requestCode. This solved the problem for me too.
I'm using phonegap for creating android apps. I created successfully a notification on the android's notification bar with the plugin localnotification here: https://github.com/phonegap/phonegap-plugins/tree/master/Android/LocalNotification
Now I want to create a alarm (a kind of seeting alarm in clock), I see some .java file in this plugin has the titles with [alarm...], I think I can do something with this plugin. But I cannot find the examples for this.
Please give me some examples for this kind.
Thanks guys.
After searching on google, I see that phonegap doesnot support for notification/alarm. And the plugin [localnotification] for android just supports for showing the notification on notification bar. That's it.
Maybe to show an alarm, we need to write an other plugin with some java codes, and using the tutorial how to create a plugin with phonegap at here: http://docs.phonegap.com/en/2.1.0/guide_plugin-development_android_index.md.html#Developing%20a%20Plugin%20on%20Android