Created
June 5, 2024 19:22
-
-
Save MkhytarMkhoian/aceae48644489e7f20863bd5c7450ef7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FirebaseDynamicLinkDataSource( | |
private val host: String, | |
private val firebaseDynamicLinks: FirebaseDynamicLinks, | |
private val backgroundDispatcher: CoroutineDispatcher = Dispatchers.IO, | |
) { | |
suspend fun parseLink(uri: String): String? = withContext(backgroundDispatcher) { | |
if (uri.matchesPattern(host).not()) return@withContext null | |
try { | |
firebaseDynamicLinks.getDynamicLink(Uri.parse(uri)).await().link?.toString() | |
} catch (e: Exception) { | |
throw DynamicLinkParseException(cause = e) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment