From 27d2acf5221681f3410ca58d601e6331f2a6a59f Mon Sep 17 00:00:00 2001 From: "hirotaka.akita" Date: Tue, 30 Jan 2024 18:45:50 +0900 Subject: [PATCH 1/6] add setStyle notification bigPictureStyle --- .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index 58483d375f..f58c188361 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -134,6 +134,11 @@ class PushNotificationsUtils( setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon) + setStyle( + NotificationCompat.BigPictureStyle() + .bigPicture(largeImageIcon) + .bigLargeIcon(null) + ) setAutoCancel(true) } From 31a006ad000bb06763cd6f5f1a5efd8ccc7e14c9 Mon Sep 17 00:00:00 2001 From: "OWNER-PC\\OWNER" Date: Sat, 17 Feb 2024 16:21:34 +0900 Subject: [PATCH 2/6] add large icon entrance --- .../pinpoint/PinpointNotificationPayload.kt | 5 ++++- .../pinpoint/PushNotificationsConstants.kt | 2 ++ .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt index d014b29db5..698db258ae 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt @@ -24,6 +24,7 @@ class PinpointNotificationPayload internal constructor( val title: String? = null, val body: String? = null, val imageUrl: String? = null, + val largeImageUrl: String? = null, val action: Map = mapOf(), val silentPush: Boolean = false, channelId: String? = null, @@ -45,6 +46,8 @@ class PinpointNotificationPayload internal constructor( ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_BODY] val imageUrl = data[PushNotificationsConstants.IMAGEURL] ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_IMAGEURL] + val largeImageUrl = data[PushNotificationsConstants.LARGEIMAGEURL] + ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_LARGEIMAGEURL] val channelId = payload.channelId ?: PushNotificationsConstants.DEFAULT_NOTIFICATION_CHANNEL_ID val silentPush = data[PushNotificationsConstants.PINPOINT_NOTIFICATION_SILENTPUSH].equals("1") val action: MutableMap = mutableMapOf() @@ -62,7 +65,7 @@ class PinpointNotificationPayload internal constructor( } return PinpointNotificationPayload( - title, body, imageUrl, + title, body, imageUrl, largeImageUrl, action, silentPush, channelId, payload.targetClass, payload.contentProvider ) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt index 66ec9cc465..2ebb849d89 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt @@ -29,6 +29,7 @@ class PushNotificationsConstants { const val TITLE = "title" // title const val MESSAGE = "message" // message const val IMAGEURL = "imageUrl" // imageUrl + const val LARGEIMAGEURL = "largeImageUrl" // largeImageUrl const val JOURNEY = "journey" // journey const val JOURNEY_ID = "journey_id" // journey_id const val JOURNEY_ACTIVITY_ID = "journey_activity_id" // journey_activity_id @@ -38,6 +39,7 @@ class PushNotificationsConstants { const val PINPOINT_NOTIFICATION_TITLE = "$NOTIFICATION_PREFIX$TITLE" // pinpoint.notification.title const val PINPOINT_NOTIFICATION_BODY = "${NOTIFICATION_PREFIX}body" // pinpoint.notification.body const val PINPOINT_NOTIFICATION_IMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.imageUrl + const val PINPOINT_NOTIFICATION_LARGEIMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.largeImageUrl // pinpoint.notification.silentPush const val PINPOINT_NOTIFICATION_SILENTPUSH = "${NOTIFICATION_PREFIX}silentPush" const val CAMPAIGN_ID = "campaign_id" // campaign_id diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index f58c188361..0c89212ce2 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -25,11 +25,13 @@ import android.content.Context import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.graphics.drawable.Icon import android.os.Build import androidx.annotation.ChecksSdkIntAtLeast import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.IconCompat import com.amplifyframework.pushnotifications.pinpoint.common.R import java.net.URL import kotlinx.coroutines.CoroutineScope @@ -110,7 +112,8 @@ class PushNotificationsUtils( targetClass: Class<*>? ) { CoroutineScope(Dispatchers.IO).launch { - val largeImageIcon = payload.imageUrl?.let { downloadImage(it) } + val imageIcon = payload.imageUrl?.let { downloadImage(it) } + val largeImageIcon = payload.largeImageUrl?.let { downloadImage(it) } val notificationIntent = Intent(context, payload.targetClass ?: targetClass) notificationIntent.putExtra("amplifyNotificationPayload", payload) notificationIntent.putExtra("notificationId", notificationId) @@ -130,7 +133,7 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - setSmallIcon(R.drawable.ic_launcher_foreground) + setSmallIcon(IconCompat.createWithBitmap(imageIcon)) setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon) From 6081c20f6cb5c06b4cecf47ffdf6dfb364bb2f02 Mon Sep 17 00:00:00 2001 From: "OWNER-PC\\OWNER" Date: Sat, 17 Feb 2024 16:28:33 +0900 Subject: [PATCH 3/6] Consider compatibility --- .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index 0c89212ce2..6d58332a73 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -133,7 +133,11 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - setSmallIcon(IconCompat.createWithBitmap(imageIcon)) + if(imageIcon == null) { + setSmallIcon(R.drawable.ic_launcher_foreground) + } else { + setSmallIcon(IconCompat.createWithBitmap(imageIcon)) + } setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon) From adb4d8c1712d7c92be6e127d7b4a4493ebd2f494 Mon Sep 17 00:00:00 2001 From: "OWNER-PC\\OWNER" Date: Tue, 20 Feb 2024 23:21:41 +0900 Subject: [PATCH 4/6] Revert "Consider compatibility" This reverts commit 6081c20f6cb5c06b4cecf47ffdf6dfb364bb2f02. --- .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index 6d58332a73..0c89212ce2 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -133,11 +133,7 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - if(imageIcon == null) { - setSmallIcon(R.drawable.ic_launcher_foreground) - } else { - setSmallIcon(IconCompat.createWithBitmap(imageIcon)) - } + setSmallIcon(IconCompat.createWithBitmap(imageIcon)) setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon) From 4ed9db3f211181bf23d3cf343f66285f575bca1c Mon Sep 17 00:00:00 2001 From: "OWNER-PC\\OWNER" Date: Tue, 20 Feb 2024 23:21:52 +0900 Subject: [PATCH 5/6] Revert "add large icon entrance" This reverts commit 31a006ad000bb06763cd6f5f1a5efd8ccc7e14c9. --- .../pinpoint/PinpointNotificationPayload.kt | 5 +---- .../pinpoint/PushNotificationsConstants.kt | 2 -- .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 7 ++----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt index 698db258ae..d014b29db5 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt @@ -24,7 +24,6 @@ class PinpointNotificationPayload internal constructor( val title: String? = null, val body: String? = null, val imageUrl: String? = null, - val largeImageUrl: String? = null, val action: Map = mapOf(), val silentPush: Boolean = false, channelId: String? = null, @@ -46,8 +45,6 @@ class PinpointNotificationPayload internal constructor( ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_BODY] val imageUrl = data[PushNotificationsConstants.IMAGEURL] ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_IMAGEURL] - val largeImageUrl = data[PushNotificationsConstants.LARGEIMAGEURL] - ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_LARGEIMAGEURL] val channelId = payload.channelId ?: PushNotificationsConstants.DEFAULT_NOTIFICATION_CHANNEL_ID val silentPush = data[PushNotificationsConstants.PINPOINT_NOTIFICATION_SILENTPUSH].equals("1") val action: MutableMap = mutableMapOf() @@ -65,7 +62,7 @@ class PinpointNotificationPayload internal constructor( } return PinpointNotificationPayload( - title, body, imageUrl, largeImageUrl, + title, body, imageUrl, action, silentPush, channelId, payload.targetClass, payload.contentProvider ) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt index 2ebb849d89..66ec9cc465 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt @@ -29,7 +29,6 @@ class PushNotificationsConstants { const val TITLE = "title" // title const val MESSAGE = "message" // message const val IMAGEURL = "imageUrl" // imageUrl - const val LARGEIMAGEURL = "largeImageUrl" // largeImageUrl const val JOURNEY = "journey" // journey const val JOURNEY_ID = "journey_id" // journey_id const val JOURNEY_ACTIVITY_ID = "journey_activity_id" // journey_activity_id @@ -39,7 +38,6 @@ class PushNotificationsConstants { const val PINPOINT_NOTIFICATION_TITLE = "$NOTIFICATION_PREFIX$TITLE" // pinpoint.notification.title const val PINPOINT_NOTIFICATION_BODY = "${NOTIFICATION_PREFIX}body" // pinpoint.notification.body const val PINPOINT_NOTIFICATION_IMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.imageUrl - const val PINPOINT_NOTIFICATION_LARGEIMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.largeImageUrl // pinpoint.notification.silentPush const val PINPOINT_NOTIFICATION_SILENTPUSH = "${NOTIFICATION_PREFIX}silentPush" const val CAMPAIGN_ID = "campaign_id" // campaign_id diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index 0c89212ce2..f58c188361 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -25,13 +25,11 @@ import android.content.Context import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory -import android.graphics.drawable.Icon import android.os.Build import androidx.annotation.ChecksSdkIntAtLeast import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat -import androidx.core.graphics.drawable.IconCompat import com.amplifyframework.pushnotifications.pinpoint.common.R import java.net.URL import kotlinx.coroutines.CoroutineScope @@ -112,8 +110,7 @@ class PushNotificationsUtils( targetClass: Class<*>? ) { CoroutineScope(Dispatchers.IO).launch { - val imageIcon = payload.imageUrl?.let { downloadImage(it) } - val largeImageIcon = payload.largeImageUrl?.let { downloadImage(it) } + val largeImageIcon = payload.imageUrl?.let { downloadImage(it) } val notificationIntent = Intent(context, payload.targetClass ?: targetClass) notificationIntent.putExtra("amplifyNotificationPayload", payload) notificationIntent.putExtra("notificationId", notificationId) @@ -133,7 +130,7 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - setSmallIcon(IconCompat.createWithBitmap(imageIcon)) + setSmallIcon(R.drawable.ic_launcher_foreground) setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon) From 1ab527e2f35a7c9f8ecf348aa95018a0bab31e36 Mon Sep 17 00:00:00 2001 From: "OWNER-PC\\OWNER" Date: Tue, 20 Feb 2024 23:24:39 +0900 Subject: [PATCH 6/6] set large image icon for small icon --- .../pushnotifications/pinpoint/PushNotificationsUtils.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index f58c188361..78153f75f3 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -30,6 +30,7 @@ import androidx.annotation.ChecksSdkIntAtLeast import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.IconCompat import com.amplifyframework.pushnotifications.pinpoint.common.R import java.net.URL import kotlinx.coroutines.CoroutineScope @@ -130,7 +131,7 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - setSmallIcon(R.drawable.ic_launcher_foreground) + setSmallIcon(IconCompat.createWithBitmap(largeImageIcon)) setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon)