-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please supoort android 13 #88
Comments
It works with my android 13 device(API 33), example is: /** ref link: https://github.com/navczydev/NotificationPermissionAndroid13/blob/master/app/src/main/java/com/example/myapplication/MainActivity.kt#L50 */
private fun sendANotification() {
when {
ContextCompat.checkSelfPermission(
this, Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED -> {
// You can use the API that requires the permission.
sendNotification(this)
}
shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS) -> {
Snackbar.make(
findViewById(R.id.main),
"Notification blocked",
Snackbar.LENGTH_LONG
).setAction("Settings") {
// Responds to click on the action
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val uri: Uri = Uri.fromParts("package", packageName, null)
intent.data = uri
startActivity(intent)
}.show()
}
else -> {
// You can directly ask for the permission.
// The registered ActivityResultCallback gets the result of this request.
if (Build.VERSION.SDK_INT >= 33) {
requestPermissionLauncher.launch(
Manifest.permission.POST_NOTIFICATIONS
)
}
}
}
/** ref link: https://github.com/Karn/notify*/
Notify
.with(this)
.content { // this: Payload.Content.Default
title = "你好呀"
text = "哈哈哈"
}
.show()
} use this by the way, I install the apk twice to fix Notification show up problem, it seems grant |
Please adapt to Android13 dynamic application notification permission
The text was updated successfully, but these errors were encountered: