I'm facing unwelcome behavior when asking new POST_NOTIFICATIONS
permission on some particular device owned by remote tester - Pixel 4a (Android 13). Sadly don't have logs and "cable access". Freshly installed app - still targetting API30, but also tried with target set to 33, just for test - should show custom splashscreen Activity
, after that shows "main" Activity
, which in onResume
tries to create NotificationChannel
. This should cause perm dialog pop up
If your app targets 12L (API level 32) or lower, the system shows the permission dialog the first time your app starts an activity after you create a notification channel, or when your app starts an activity and then creates its first notification channel. This is usually on app startup.
Well, not on this Pixel 4a with Android 13, meanwhile on Pixel 6 with Android 13 dialog shows up...
Funniest thing is... When tester install app, runs first time, no dialog, then kill it, navigate to system settings and clear data/cache (or even won't make first run, just clean after installation), then dialogs shows up at "first" run...
Why?!
Edit: so now I can reproduce problem also on Pixel 6. I've introduced middle-Dialog
with info about content in pushes/notifications and simple yes/no buttons. "Yes" is creating (first) NotificationChannel
and this doesn't cause POST_NOTIFICATIONS
perm dialog appearance...
@RequiresApi(Build.VERSION_CODES.O)
fun addStaticNotificationChannel(channelId: String, nameResId: Int, descriptionResId: Int,
importance: Int, soundOn: Boolean = true, forceRecreate: Boolean = false): String {
val name = context.resources.getText(nameResId).toString()
val description = context.resources.getText(descriptionResId).toString()
/*if (manager.getNotificationChannel(channelId) != null) {
if (forceRecreate) manager.deleteNotificationChannel(channelId)
else return channelId
}*/
val channel = NotificationChannel(channelId, name, importance)
channel.description = description
channel.lockscreenVisibility = VISIBILITY_PUBLIC
channel.setShowBadge(true)
channel.enableLights(true)
channel.lightColor = ContextCompat.getColor(context, R.color.tsi_blue)
if (!soundOn)
channel.setSound(null, null)
Log.i(this.javaClass.simpleName, "createNotificationChannel channeldId:$channelId")
manager.createNotificationChannel(channel)
return channelId
}