Not sure whether this is intended behaviour or I am doing something wrong. I upgraded an older app to target SDK 34. The app has a foregroundservice. According to the docs I need to show a notification to the user while being in foreground mode.
I added the permission "POST_NOTIFICATIONS". (Also: FOREGROUND_SERVICE and FOREGROUND_SERVICE_MEDIA_PLAYBACK. And foregroundServiceType is mediaPlayback) Now when I install the app, the notification does not show when it goes in foreground mode. Only when I go into my devices' settings->Notifications->App notifications and switch the notifications on for my app, the notification shows as intended. Alternatively, I am able to ask runtime permission to show the notification, and the notification indeed shows once the user allows it.
My question: is it normal behaviour that the notification is not shown (whereas it is a prerequisite for forground mode)? Should I ask permission when the user opens the app for the first time? Or should I use some other permission to avoid haveing the user to do some action before the notification required by Android is shown?
According to your question and statement you stated notification shows when user allow the permission then you should ask for permission or not?
then would say it is necessary to ask for notification permission from android 13 without that you can't show notification to user ,you can ask for runtime permission as used to do for camera ,external storage etc.