Ask for permission to post notifications (SDK 33)
This commit is contained in:
parent
abeae71b0c
commit
92ec2d753f
3 changed files with 17 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28"/> <!-- Only required on SDK <= 28 -->
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/> <!-- To install packages downloaded through ntfy; craazyy! -->
|
||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/> <!-- To reschedule the websocket retry -->
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/> <!-- As of Android 13, we need to ask for permission to post notifications -->
|
||||
|
||||
<application
|
||||
android:name=".app.Application"
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package io.heckel.ntfy.ui
|
||||
|
||||
import android.Manifest
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.app.AlertDialog
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
|
@ -20,6 +22,7 @@ import android.widget.Toast
|
|||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -208,6 +211,18 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
|||
schedulePeriodicPollWorker()
|
||||
schedulePeriodicServiceRestartWorker()
|
||||
schedulePeriodicDeleteWorker()
|
||||
|
||||
// Permissions
|
||||
maybeRequestNotificationPermission()
|
||||
}
|
||||
|
||||
private fun maybeRequestNotificationPermission() {
|
||||
// Android 13 (SDK 33) requires that we ask for permission to post notifications
|
||||
// https://developer.android.com/develop/ui/views/notifications/notification-permission
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_DENIED) {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.POST_NOTIFICATIONS), 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Bug fixes + maintenance:
|
||||
* Upgrade Android dependencies to SDK 33 (no ticket)
|
||||
* Android 13: Ask for permission to post notifications (#508)
|
||||
* Remove timestamp when copying message text (#471, thanks to @wunter8)
|
||||
|
||||
Additional translations:
|
||||
|
|
Loading…
Reference in a new issue