I am trying to setup google payment via chrometab in a project, and despite it opening properly, I cannot find a way to, upon closing, inform the webview the chrometab is above, about the current url (/success or /failure).
Chrometab seems to not provide a callback, and intents, unless my fault, do not work
Any help?
enum class BrowserMethods {
CHROME_TAB, BROWSER
}
internal fun openCustomTab(
context: Context,
methods: BrowserMethods = BrowserMethods.CHROME_TAB,
url: String,
) {
val uri = Uri.parse(url)
when (methods) {
BrowserMethods.CHROME_TAB ->
try {
openChromeTab(
context = context,
uri = uri
)
} catch (e: Exception) {
openBrowser(
context = context,
uri = uri
)
}
BrowserMethods.BROWSER ->
openBrowser(
context = context,
uri = uri
)
}
}
private fun openChromeTab(
context: Context,
uri: Uri
) {
val intent: CustomTabsIntent = CustomTabsIntent
.Builder()
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
.build()
intent.launchUrl(context, uri)
}
private fun openBrowser(
context: Context,
uri: Uri
) {
val intent = Intent(Intent.ACTION_VIEW, uri)
context.startActivity(intent)
}