Deeplink: handle notification click to open a room.
This commit is contained in:
parent
018a5c540a
commit
b0f14bfb15
17 changed files with 292 additions and 33 deletions
|
|
@ -25,9 +25,7 @@ interface IntentProvider {
|
|||
/**
|
||||
* Provide an intent to start the application.
|
||||
*/
|
||||
fun getMainIntent(): Intent
|
||||
|
||||
fun getIntent(
|
||||
fun getViewIntent(
|
||||
sessionId: SessionId,
|
||||
roomId: RoomId?,
|
||||
threadId: ThreadId?,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ data class NotificationActionIds @Inject constructor(
|
|||
val smartReply = "${buildMeta.applicationId}.NotificationActions.SMART_REPLY_ACTION"
|
||||
val dismissSummary = "${buildMeta.applicationId}.NotificationActions.DISMISS_SUMMARY_ACTION"
|
||||
val dismissRoom = "${buildMeta.applicationId}.NotificationActions.DISMISS_ROOM_NOTIF_ACTION"
|
||||
val tapToView = "${buildMeta.applicationId}.NotificationActions.TAP_TO_VIEW_ACTION"
|
||||
val diagnostic = "${buildMeta.applicationId}.NotificationActions.DIAGNOSTIC"
|
||||
val push = "${buildMeta.applicationId}.PUSH"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,15 +482,11 @@ class NotificationUtils @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buildOpenRoomIntent(sessionId: SessionId, roomId: RoomId): PendingIntent? {
|
||||
val roomIntent = intentProvider.getIntent(sessionId = sessionId, roomId = roomId, threadId = null)
|
||||
roomIntent.action = actionIds.tapToView
|
||||
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that
|
||||
roomIntent.data = createIgnoredUri("openRoom?$sessionId&$roomId")
|
||||
|
||||
val intent = intentProvider.getViewIntent(sessionId = sessionId, roomId = roomId, threadId = null)
|
||||
return PendingIntent.getActivity(
|
||||
context,
|
||||
clock.epochMillis().toInt(),
|
||||
roomIntent,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
|
@ -498,22 +494,17 @@ class NotificationUtils @Inject constructor(
|
|||
private fun buildOpenThreadIntent(roomInfo: RoomEventGroupInfo, threadId: ThreadId?): PendingIntent? {
|
||||
val sessionId = roomInfo.sessionId
|
||||
val roomId = roomInfo.roomId
|
||||
val threadIntentTap = intentProvider.getIntent(sessionId = sessionId, roomId = roomId, threadId = threadId)
|
||||
threadIntentTap.action = actionIds.tapToView
|
||||
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that
|
||||
threadIntentTap.data = createIgnoredUri("openThread?$sessionId&$roomId&$threadId")
|
||||
|
||||
val intent = intentProvider.getViewIntent(sessionId = sessionId, roomId = roomId, threadId = threadId)
|
||||
return PendingIntent.getActivity(
|
||||
context,
|
||||
clock.epochMillis().toInt(),
|
||||
threadIntentTap,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
)
|
||||
}
|
||||
|
||||
private fun buildOpenHomePendingIntentForSummary(sessionId: SessionId): PendingIntent {
|
||||
val intent = intentProvider.getIntent(sessionId = sessionId, roomId = null, threadId = null)
|
||||
intent.data = createIgnoredUri("tapSummary?$sessionId")
|
||||
val intent = intentProvider.getViewIntent(sessionId = sessionId, roomId = null, threadId = null)
|
||||
return PendingIntent.getActivity(
|
||||
context,
|
||||
clock.epochMillis().toInt(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue