My app targets API 33 (Android 13), and runs a foreground service to play online music.

Once the notification is started via startForeground(notification_Id, notification), I can update the notification via notificationManager.notify(notification_Id, notification). However, Android Studio tells me that the android.permission.POST_NOTIFICATIONS permission is missing.

Even though I include that permission in the AndroidManifest, I don't need to ask the user to grant the permission to update the notification.

Is this method of updating the notification is valid or is it a security hole? Obviously the method works, but I have not found any reference in the documentation of Android 13+

2

There are 2 best solutions below

1
János Sicz-Mesziár On BEST ANSWER

Even though I include that permission in the AndroidManifest, I don't need to ask the user to grant the permission to update the notification.

Can anyone confirm if this method of updating the notification is valid or is it a security hole? Obviously the method works but I have not found any reference in the documentation of Android 13+

That's fine. No security hole. There are some exemptions that do not require the POST_NOTIFICATIONS permission. According to the official documentation, notifications related to media sessions are exempt from this behavior change. MediaStyle uses media session to build up the notification.

0
Shashank Munda On

POST_NOTIFICATION permission provides the end-user the ability to decide which notifications are of significance to him/her. For updating the notification, you don't require any additional permission, just as you could do before. However, it seems like you aren't using the MediaPack3 for managing playback,because as per the documentation, Notifications related to media sessions are exempt from this behavior change.