Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Notifications redirect to sample app, not dapp url #1289

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
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 @@ -102,7 +102,7 @@
.collect {
val collected = buffer.toList()
send(transform(collected))
buffer.removeAll(collected)

Check notice on line 105 in sample/wallet/src/main/kotlin/com/walletconnect/sample/wallet/domain/NotificationHandler.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for Android

Argument could be converted to 'Set' to improve performance

The argument can be converted to 'Set' to improve performance
}
}

Expand Down Expand Up @@ -148,8 +148,7 @@
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 @@
}
}

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
Loading