BRD*_*oid 7 android push-notification android-manifest kotlin android-permissions
我将 targetSdkVersion 从 30 更新到 33,并且在设备上安装应用程序时不显示通知弹出窗口
当 targetSdkVersion 为 30 并且安装应用程序时,会显示以下弹出窗口,当我单击“允许”时,我会收到通知
当 targetSdkVersion 为 33 时,安装应用程序时我没有收到以下弹出窗口。我查看了https://developer.android.com/develop/ui/views/notifications/notification-permission
并添加<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
到清单文件中。我仍然没有收到任何请求通知许可的提示。
我有代码检查通知是否已启用,并且由于没有显示提示而返回 null。
private fun isNotificationsEnabled(): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val manager = oApp.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (!manager.areNotificationsEnabled()) {
return false
}
val channels = manager.notificationChannels
for (channel in channels) {
if (channel.importance == NotificationManager.IMPORTANCE_NONE) {
return false
}
}
true
} else {
NotificationManagerCompat.from(oApp).areNotificationsEnabled()
}
}
Run Code Online (Sandbox Code Playgroud)
我如何强制提示或我还需要做什么才能让用户在首次安装时收到此提示
提前致谢
归档时间: |
|
查看次数: |
5990 次 |
最近记录: |