Skip to content

Commit

Permalink
fix(android): prevent permission dialog appearing when already denied (
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu authored Dec 7, 2024
1 parent dbceb88 commit 82776b4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/android/com/adobe/phonegap/push/PushPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ class PushPlugin : CordovaPlugin() {
pushContext = callbackContext
pluginInitData = data;

var hasPermission = checkForPostNotificationsPermission()
if (!hasPermission)
if (!checkForPostNotificationsPermission()) {
return
}

cordova.threadPool.execute(Runnable {
Log.v(TAG, formatLogMessage("Data=$data"))
Expand Down Expand Up @@ -612,8 +612,13 @@ class PushPlugin : CordovaPlugin() {

private fun checkForPostNotificationsPermission(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
if (!PermissionHelper.hasPermission(this, Manifest.permission.POST_NOTIFICATIONS))
{
if (!PermissionHelper.hasPermission(this, Manifest.permission.POST_NOTIFICATIONS)) {
if (ActivityCompat.shouldShowRequestPermissionRationale(
activity,
Manifest.permission.POST_NOTIFICATIONS
)) {
return false
}
PermissionHelper.requestPermission(
this,
REQ_CODE_INITIALIZE_PLUGIN,
Expand All @@ -622,7 +627,6 @@ class PushPlugin : CordovaPlugin() {
return false
}
}

return true
}

Expand Down

0 comments on commit 82776b4

Please sign in to comment.