Skip to content

Commit

Permalink
feat: Notifications redirect to sample app, not dapp url
Browse files Browse the repository at this point in the history
  • Loading branch information
Elyniss committed Jan 26, 2024
1 parent 7a11564 commit a4ab31f
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object NotificationHandler {
data class Simple(override val messageId: Int, override val channelId: String, override val title: String, override val body: String) : Notification

data class Decrypted(
override val messageId: Int, override val channelId: String, override val title: String, override val body: String, val topic: String, val url: String?
override val messageId: Int, override val channelId: String, override val title: String, override val body: String, val topic: String, val url: String?,
) : Notification //Notify

data class SessionProposal(
Expand Down Expand Up @@ -148,8 +148,7 @@ object NotificationHandler {
Triple(notification.messageId, notification.title, notification.body)
}

val url = (notifications.first() as? Notification.Decrypted)?.url
val pendingIntent = buildPendingIntent(context, url)
val pendingIntent = buildPendingIntent(context)

showNotification(
context = context,
Expand All @@ -171,13 +170,8 @@ object NotificationHandler {
}
}

private fun buildPendingIntent(context: Context, url: String?): PendingIntent {
val parsedUrl = kotlin.runCatching { Uri.parse(url) }.getOrNull()
val intent = if (parsedUrl == null) {
Intent(context, Web3WalletActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) }
} else {
Intent(Intent.ACTION_VIEW, parsedUrl)
}
private fun buildPendingIntent(context: Context): PendingIntent {
val intent = Intent(context, Web3WalletActivity::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) }
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
}

Expand Down

0 comments on commit a4ab31f

Please sign in to comment.