ryanheise / just_audio

Audio Player
1.03k stars 638 forks source link

How to show app's icon in notification panel ? #619

Open abbas2501 opened 2 years ago

abbas2501 commented 2 years ago

Is your feature request related to a problem? Please describe. Yep - I want to know how can I show my app's icon beside the app's name instead of the default white circle.

Describe the solution you'd like

Describe alternatives you've considered None

Additional context WhatsApp Image 2021-12-28 at 9 51 56 AM

ryanheise commented 2 years ago

I have changed this to a documentation request. There is a parameter to init called androidNotificationIcon where you can pass in the icon, but the icon is supposed to be monochrome white anyway - consult Android docs for more information on Android's requirements.

ryanheise commented 2 years ago

Reopening since the documentation still hasn't been written.

adrianvintu commented 2 years ago

Would be great to know how to input the path. Anyone got this working?

rupinderjeet commented 2 years ago

@adrianvintu I hope you have the solution by now. If not, here's how I do it.

In audio_service, default value of androidNotificationIcon parameter is mipmap/ic_launcher which is the launcher icon of your app.

If you already have notification icon, place it in android/app/src/main/res/drawable folder. If you have multiple variations of same icon, place them in related drawable-x folder. Remember that the icon needs to be monochrome because system will tint it.

If you don't have a notification icon, you can generate it from Android Asset Studio by choosing Notification Icon Generator. When you download the zip file of icons, you can place them in above mentioned folders.

In AudioServiceConfig, I use downloaded icons like this (assuming ic_notification.png is file name):

AudioServiceConfig(
       androidNotificationIcon: "drawable/ic_notification",
 )
adrianvintu commented 2 years ago

Thank you so much @rupinderjeet, that is great explanation, I hope it makes it to the documentation.

This is important Remember that the icon needs to be monochrome because system will tint it., to make it show properly in the emulator.

ryanheise commented 2 years ago

The documentation currently just contains a reference to audio_service:

https://pub.dev/documentation/just_audio_background/latest/just_audio_background/JustAudioBackground/init.html

Each parameter controls a behaviour in audio_service. Consult audio_service's AudioServiceConfig API documentation for more information.

which I guess is technically correct, but yes it could be improved by copying and pasting the audio_service documentation over to just_audio_background and also adding the link to Android Asset Studio (which maybe I linked to in an older version of audio_service).

adrianvintu commented 2 years ago

Oh, I was thinking about the doc here https://pub.dev/packages/just_audio_background, since it's a major feature.

ryanheise commented 2 years ago

That page is not the documentation, if you search on that page for the word "documentation", you will see the documentation. I sometimes wonder whether people read the actual documentation or not.

adrianvintu commented 2 years ago

For the 65 components I use, most of the functionality is provided via the documentation on the front page. When in doubt, I use the example page or the GIT sources.

I almost never read the https://pub.dev/documentation documentation because I find it very difficult, very poorly organized, very ugly looking.

I hope this feedback helps you organize your documentation.

ryanheise commented 2 years ago

Sure a very short summary of some of the main methods appears in the README, but if what you need isn't covered in that summary, then of course you must open up the full documentation. It's not difficult because it should show up in your IDE whenever you use a method. You can also navigate from your method call into the method definition in your IDE and see the documentation directly above the method.

adrianvintu commented 2 years ago
  1. I could not get the notification icon to appear on Galaxy S10 and Emulator S running Tiramisu Api 32. I have tried with white text /transparent background. It works on Galaxy S8 with colorful icon, though.

  2. I have tried compiling the example in git https://github.com/ryanheise/just_audio/tree/minor/just_audio_background/example and uploaded to Galaxy S10 and Emulator S running Tiramisu Api 32. They both do not show the icon. The notification is there, if I drag the top bar with the finger, I can use it. But the icon is invisible. I think it's the same on iOS 13.

risfat commented 1 month ago

Same issue here. My app contains Flutter Local Notification Package . When any notification shows up there is no icon on the left of the notification after implementing just_audio_background. 🙃