我在询问新问题时面临不受欢迎的行为POST_NOTIFICATIONS
远程测试人员拥有的某些特定设备的权限 - Pixel 4a (Android 13)。遗憾的是没有日志和“电缆访问”。新安装的应用程序 - 仍然以 API30 为目标,但也尝试将目标设置为 33,只是为了测试 - 应该显示自定义启动屏幕Activity
,之后显示“main”Activity
,其中在onResume
尝试创造NotificationChannel
. 这应该会导致弹出烫发对话框 https://developer.android.com/develop/ui/views/notifications/notification-permission#new-apps
如果您的应用程序的目标版本为 12L(API 级别 32)或更低,则当您的应用程序在创建通知通道后首次启动 Activity 时,或者当您的应用程序启动 Activity 然后创建其第一个通知通道时,系统会显示权限对话框。这通常是在应用程序启动时发生的。
好吧,在装有 Android 13 的 Pixel 4a 上则不然,同时在装有 Android 13 的 Pixel 6 上会出现对话框......
最有趣的是......当测试人员安装应用程序时,第一次运行,没有对话框,然后杀死它,导航到系统设置并清除数据/缓存(甚至不会首次运行,只是在安装后清理),然后对话框显示在“第一次”运行时...
Why?!
编辑:所以现在我也可以在 Pixel 6 上重现问题。我已经介绍了中间-Dialog
包含有关推送/通知中内容的信息以及简单的是/否按钮。 “是”就是创造(第一)NotificationChannel
这不会导致POST_NOTIFICATIONS
烫发对话框外观...
@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
}