diff --git a/plugin.xml b/plugin.xml
index 689e76408..eecd05b44 100755
--- a/plugin.xml
+++ b/plugin.xml
@@ -34,9 +34,11 @@
+
+
@@ -77,8 +79,9 @@
-
+
+
diff --git a/src/android/com/adobe/phonegap/push/FCMService.kt b/src/android/com/adobe/phonegap/push/FCMService.kt
index 9f6b90a24..3494b525f 100644
--- a/src/android/com/adobe/phonegap/push/FCMService.kt
+++ b/src/android/com/adobe/phonegap/push/FCMService.kt
@@ -1,6 +1,7 @@
package com.adobe.phonegap.push
import android.annotation.SuppressLint
+import android.app.Activity
import android.app.Notification
import android.app.NotificationManager
import android.app.PendingIntent
@@ -436,19 +437,22 @@ class FCMService : FirebaseMessagingService() {
private fun createNotification(extras: Bundle?) {
val mNotificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager
val appName = getAppName(this)
+ val fullScreenIntent: Boolean = extras?.getString(PushConstants.FULL_SCREEN_NOTIFICATION, "").equals("1")
+ Log.d(TAG, "fullScreenIntent = $fullScreenIntent")
val notId = parseNotificationIdToInt(extras)
- val notificationIntent = Intent(this, PushHandlerActivity::class.java).apply {
- addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
- putExtra(PushConstants.PUSH_BUNDLE, extras)
- putExtra(PushConstants.NOT_ID, notId)
- }
+ val activityClass: Class =
+ if (fullScreenIntent) FullScreenActivity::class.java else PushHandlerActivity::class.java
+ val notificationIntent = Intent(this, activityClass)
+ notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ notificationIntent.putExtra(PushConstants.PUSH_BUNDLE, extras)
+ notificationIntent.putExtra(PushConstants.NOT_ID, notId)
val random = SecureRandom()
var requestCode = random.nextInt()
val contentIntent = PendingIntent.getActivity(
this,
requestCode,
notificationIntent,
- PendingIntent.FLAG_UPDATE_CURRENT
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
val dismissedNotificationIntent = Intent(
this,
@@ -467,7 +471,7 @@ class FCMService : FirebaseMessagingService() {
this,
requestCode,
dismissedNotificationIntent,
- PendingIntent.FLAG_CANCEL_CURRENT
+ PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE
)
val mBuilder: NotificationCompat.Builder =
@@ -479,7 +483,17 @@ class FCMService : FirebaseMessagingService() {
.setContentIntent(contentIntent)
.setDeleteIntent(deleteIntent)
.setAutoCancel(true)
-
+ if (fullScreenIntent) {
+ mBuilder
+ .setFullScreenIntent(contentIntent, true)
+ .setPriority(NotificationCompat.PRIORITY_HIGH)
+ } else {
+ mBuilder.setContentIntent(contentIntent)
+ }
+ val prefs: SharedPreferences = context.getSharedPreferences(
+ PushConstants.COM_ADOBE_PHONEGAP_PUSH,
+ Context.MODE_PRIVATE
+ )
val localIcon = pushSharedPref.getString(PushConstants.ICON, null)
val localIconColor = pushSharedPref.getString(PushConstants.ICON_COLOR, null)
val soundOption = pushSharedPref.getBoolean(PushConstants.SOUND, true)
@@ -654,7 +668,6 @@ class FCMService : FirebaseMessagingService() {
var intent: Intent?
var pIntent: PendingIntent?
val callback = action.getString(PushConstants.CALLBACK)
-
when {
inline -> {
Log.d(TAG, "Version: ${Build.VERSION.SDK_INT} = ${Build.VERSION_CODES.M}")
@@ -672,11 +685,12 @@ class FCMService : FirebaseMessagingService() {
pIntent = if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
Log.d(TAG, "push activity for notId $notId")
+
PendingIntent.getActivity(
this,
uniquePendingIntentRequestCode,
intent,
- PendingIntent.FLAG_ONE_SHOT
+ PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
)
} else {
Log.d(TAG, "push receiver for notId $notId")
@@ -685,7 +699,7 @@ class FCMService : FirebaseMessagingService() {
this,
uniquePendingIntentRequestCode,
intent,
- PendingIntent.FLAG_ONE_SHOT
+ PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_MUTABLE
)
}
}
@@ -696,7 +710,7 @@ class FCMService : FirebaseMessagingService() {
pIntent = PendingIntent.getActivity(
this, uniquePendingIntentRequestCode,
intent,
- PendingIntent.FLAG_UPDATE_CURRENT
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}
@@ -706,7 +720,7 @@ class FCMService : FirebaseMessagingService() {
pIntent = PendingIntent.getBroadcast(
this, uniquePendingIntentRequestCode,
intent,
- PendingIntent.FLAG_UPDATE_CURRENT
+ PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
)
}
}
diff --git a/src/android/com/adobe/phonegap/push/FullScreenActivity.kt b/src/android/com/adobe/phonegap/push/FullScreenActivity.kt
new file mode 100644
index 000000000..f946ea371
--- /dev/null
+++ b/src/android/com/adobe/phonegap/push/FullScreenActivity.kt
@@ -0,0 +1,85 @@
+package com.adobe.phonegap.push
+
+import android.app.Activity
+import android.app.KeyguardManager
+import android.content.Context
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.os.Build
+import android.os.Bundle
+import android.util.Log
+import android.view.WindowManager
+
+class FullScreenActivity : Activity() {
+ public override fun onCreate(savedInstanceState: Bundle?) {
+ Log.d(LOG_TAG, "onCreate")
+ super.onCreate(savedInstanceState)
+ turnScreenOnAndKeyguardOff()
+ forceMainActivityReload()
+ finish()
+ }
+
+ private fun forceMainActivityReload() {
+ val pm: PackageManager = getPackageManager()
+ val launchIntent: Intent? =
+ pm.getLaunchIntentForPackage(getApplicationContext().getPackageName())
+ launchIntent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ launchIntent?.addFlags(Intent.FLAG_FROM_BACKGROUND)
+ startActivity(launchIntent)
+ }
+
+ protected override fun onDestroy() {
+ super.onDestroy()
+ Log.d(LOG_TAG, "onDestroy")
+ turnScreenOffAndKeyguardOn()
+ }
+
+ private fun turnScreenOnAndKeyguardOff() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
+ Log.d(LOG_TAG, "setShowWhenLocked")
+ setShowWhenLocked(true)
+ setTurnScreenOn(true)
+ } else {
+ Log.d(LOG_TAG, "addFlags")
+ getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
+ )
+ }
+ val keyguardManager: KeyguardManager? = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager?
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && keyguardManager != null) {
+ keyguardManager?.requestDismissKeyguard(this, object : KeyguardManager.KeyguardDismissCallback() {
+ override fun onDismissCancelled() {
+ super.onDismissCancelled()
+ Log.d(LOG_TAG, "canceled")
+ }
+
+ override fun onDismissError() {
+ super.onDismissError()
+ Log.d(LOG_TAG, "onDismissError")
+ }
+
+ override fun onDismissSucceeded() {
+ super.onDismissSucceeded()
+ Log.d(LOG_TAG, "onDismissSucceeded")
+ }
+ })
+ }
+ }
+
+ private fun turnScreenOffAndKeyguardOn() {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
+ setShowWhenLocked(false)
+ setTurnScreenOn(false)
+ } else {
+ getWindow().clearFlags(
+ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
+ )
+ }
+ }
+
+ companion object {
+ private const val LOG_TAG = "FullScreenActivity"
+ }
+}
diff --git a/src/android/com/adobe/phonegap/push/PushConstants.kt b/src/android/com/adobe/phonegap/push/PushConstants.kt
index e403e3677..f6b7f6fe7 100644
--- a/src/android/com/adobe/phonegap/push/PushConstants.kt
+++ b/src/android/com/adobe/phonegap/push/PushConstants.kt
@@ -110,4 +110,5 @@ object PushConstants {
const val CLEAR_NOTIFICATION: String = "clearNotification"
const val MESSAGE_ID: String = "google.message_id"
const val IS_ENABLED: String = "isEnabled"
+ const val FULL_SCREEN_NOTIFICATION: String = "full-screen-notification"
}