Commit c833147e authored by Leonardo Aramaki's avatar Leonardo Aramaki

Set roomId on extras sent from the push message to the app if tap on single...

Set roomId on extras sent from the push message to the app if tap on single conversation, otherwise tapping on bundled (or grouped) conversation let the app open on the last selected roomId
parent a821fddb
...@@ -143,7 +143,7 @@ object PushManager { ...@@ -143,7 +143,7 @@ object PushManager {
private fun createGroupNotification(context: Context, lastPushMessage: PushMessage): Notification { private fun createGroupNotification(context: Context, lastPushMessage: PushMessage): Notification {
with(lastPushMessage) { with(lastPushMessage) {
val id = lastPushMessage.notificationId.toInt() val id = lastPushMessage.notificationId.toInt()
val contentIntent = getContentIntent(context, id, lastPushMessage, singleConversation = true) val contentIntent = getContentIntent(context, id, lastPushMessage, grouped = true)
val deleteIntent = getDismissIntent(context, lastPushMessage) val deleteIntent = getDismissIntent(context, lastPushMessage)
val builder = NotificationCompat.Builder(context) val builder = NotificationCompat.Builder(context)
.setWhen(createdAt) .setWhen(createdAt)
...@@ -212,7 +212,7 @@ object PushManager { ...@@ -212,7 +212,7 @@ object PushManager {
val manager: NotificationManager = val manager: NotificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val id = notificationId.toInt() val id = notificationId.toInt()
val contentIntent = getContentIntent(context, id, lastPushMessage, singleConversation = true) val contentIntent = getContentIntent(context, id, lastPushMessage, grouped = true)
val deleteIntent = getDismissIntent(context, lastPushMessage) val deleteIntent = getDismissIntent(context, lastPushMessage)
val builder = Notification.Builder(context) val builder = Notification.Builder(context)
...@@ -388,12 +388,12 @@ object PushManager { ...@@ -388,12 +388,12 @@ object PushManager {
return PendingIntent.getBroadcast(context, pushMessage.notificationId.toInt(), deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT) return PendingIntent.getBroadcast(context, pushMessage.notificationId.toInt(), deleteIntent, PendingIntent.FLAG_UPDATE_CURRENT)
} }
private fun getContentIntent(context: Context, notificationId: Int, pushMessage: PushMessage, singleConversation: Boolean = true): PendingIntent { private fun getContentIntent(context: Context, notificationId: Int, pushMessage: PushMessage, grouped: Boolean = false): PendingIntent {
val notificationIntent = Intent(context, MainActivity::class.java) val notificationIntent = Intent(context, MainActivity::class.java)
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP) notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP)
notificationIntent.putExtra(EXTRA_NOT_ID, notificationId) notificationIntent.putExtra(EXTRA_NOT_ID, notificationId)
notificationIntent.putExtra(EXTRA_HOSTNAME, pushMessage.host) notificationIntent.putExtra(EXTRA_HOSTNAME, pushMessage.host)
if (singleConversation) { if (!grouped) {
notificationIntent.putExtra(EXTRA_ROOM_ID, pushMessage.rid) notificationIntent.putExtra(EXTRA_ROOM_ID, pushMessage.rid)
} }
return PendingIntent.getActivity(context, randomizer.nextInt(), notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT) return PendingIntent.getActivity(context, randomizer.nextInt(), notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment