Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter persistent notification and service

I'm planning to develop simple audio player, but currently I'm stuck on notification support. I want notification that is persistent while audio is playing and I also need some controls (like play/pause, next/previous) and possibly fanart visible on notification. That's similar as most other player do (Aimp, Google Play Music etc).

I was looking forward for good example how to develop it using Dart/Flutter, well is that even possible without writing native code for each platform (Android/iOS)? Is there any plugin that supports that kind of notification on both platforms? Plus, of course, foreground service bound to it to don't kill audio playback when screen is off.

like image 484
user1209216 Avatar asked Dec 20 '19 11:12

user1209216


People also ask

What is Flutter_local_notifications?

A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.

How do you send notifications to all users on Flutter?

Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices.

How do I schedule notifications on Flutter?

After the Initialization, the notification can be scheduled using zonedschedule() method. In that, we should give notification details like Title, description, etc. Android and iOS get their own notification details like android has channels, so we should give channel id, channel name, importance, priority, etc.

How do you handle notifications on Flutter?

In the main app target, select Signing & Capabilities > All > + Capability and then search "push." Double-click on Push Notifications to enable it. Next, enable Background Modes and check Remote Notifications. Now you are ready to send notifications from the OneSignal dashboard!


1 Answers

You might be interested in looking at package:audio_service which seems like it might handle the majority of the work for you, including the handling of background execution and notifications.

Also, for notifications I've had success with package:flutter_local_notifications but you shouldn't need this if you're going to use package:audio_service.

like image 127
Ben Konyi Avatar answered Sep 19 '22 14:09

Ben Konyi