Skip to content

Commit

Permalink
restore selecting flag for os version
Browse files Browse the repository at this point in the history
  • Loading branch information
pmtkh committed Aug 16, 2022
1 parent fe398f6 commit 72ee17b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
28 changes: 6 additions & 22 deletions src/android/com/adobe/phonegap/push/FCMService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,11 @@ class FCMService : FirebaseMessagingService() {
notificationIntent.putExtra(PushConstants.NOT_ID, notId)
val random = SecureRandom()
var requestCode = random.nextInt()
val updateActivityFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}
val contentIntent = PendingIntent.getActivity(
this,
requestCode,
notificationIntent,
updateActivityFlag
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
val dismissedNotificationIntent = Intent(
this,
Expand All @@ -472,16 +467,11 @@ class FCMService : FirebaseMessagingService() {

requestCode = random.nextInt()

val deleteActivityFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE
} else {
PendingIntent.FLAG_CANCEL_CURRENT
}
val deleteIntent = PendingIntent.getBroadcast(
this,
requestCode,
dismissedNotificationIntent,
deleteActivityFlag
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE
)

val mBuilder: NotificationCompat.Builder =
Expand Down Expand Up @@ -697,12 +687,6 @@ class FCMService : FirebaseMessagingService() {

updateIntent(intent, callback, extras, foreground, notId)

val oneShotActivityFlag = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
} else {
PendingIntent.FLAG_ONE_SHOT
}

pIntent = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
Log.d(TAG, "push activity for notId $notId")

Expand All @@ -711,7 +695,7 @@ class FCMService : FirebaseMessagingService() {
this,
uniquePendingIntentRequestCode,
intent,
oneShotActivityFlag
oneShotActivityFlagPendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
)
} else {
Log.d(TAG, "push receiver for notId $notId")
Expand All @@ -720,7 +704,7 @@ class FCMService : FirebaseMessagingService() {
this,
uniquePendingIntentRequestCode,
intent,
oneShotActivityFlag
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
)
}
}
Expand All @@ -731,7 +715,7 @@ class FCMService : FirebaseMessagingService() {
pIntent = PendingIntent.getActivity(
this, uniquePendingIntentRequestCode,
intent,
updateActivityFlag
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}

Expand All @@ -741,7 +725,7 @@ class FCMService : FirebaseMessagingService() {
pIntent = PendingIntent.getBroadcast(
this, uniquePendingIntentRequestCode,
intent,
updateActivityFlag
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/android/com/adobe/phonegap/push/FullScreenActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FullScreenActivity : Activity() {
keyguardManager?.requestDismissKeyguard(this, object : KeyguardManager.KeyguardDismissCallback() {
override fun onDismissCancelled() {
super.onDismissCancelled()
Log.d("keygurd", "canceled")
Log.d(LOG_TAG, "canceled")
}

override fun onDismissError() {
Expand Down

0 comments on commit 72ee17b

Please sign in to comment.