Unico IDPay - DevCenter
HomepageAutenticaçãoAPI Reference
English
English
  • Introduction
  • ABOUT IDPAY
    • Unico ID Pay
    • Features
    • Use Cases
    • Chargeback
  • INTEGRATION
    • Overview
    • Authentication
      • Creating a Service Account
      • Preparing to make an authenticated request to the API
      • Additional resources
        • Example in JavaScript
        • Authentication Errors
        • Postman Collection
    • APIs
      • API Reference
        • Payment transactions
        • Chargeback
        • Credit card onboarding
      • Errors
      • Enumerated
    • Webhook
    • Controlling the experience
      • Overview
      • Requirements
      • Mobile
        • Android
        • Flutter
        • iOS
          • WKWebView
          • ASWebAuthenticationSession
      • Web
        • SDK
        • Redirect (deprecated)
    • Customizations
  • HELP & FAQ
    • FAQ
    • Best communication practices
    • Help Center
Powered by GitBook

Copyright © 2024 unico. All rights reserved.

On this page

Was this helpful?

Export as PDF
  1. INTEGRATION
  2. Controlling the experience
  3. Mobile

Android

In this section, you will find how to implement the webview on Android for using the Unico IDPay product.


For the Android use case, using a Webview is recommended.

After creating the transaction and obtaining the transaction link, the following implementation is recommended:

  • In your regular flow (where IDPay is integrated), you will open the Webview with the link generated via API.

  • You can customize how this opening works in the way that best fits your application.

  • You will monitor if there is a URL change (to the redirectUrl) and then close the Webview.

Opening a Webview is quite simple:

import android.webkit.PermissionRequest
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient

@SuppressLint("SetJavaScriptEnabled")
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_camera)

    findViewById<WebView>(R.id.webView).apply {
        settings.javaScriptEnabled = true
        settings.domStorageEnabled = true
        settings.mediaPlaybackRequiresUserGesture = false
        clearCache(true)
        webViewClient = myWebViewClient
        webChromeClient = object : WebChromeClient() {
            override fun onPermissionRequest(request: PermissionRequest?) {
                request?.grant(request.resources)
            }
        }
        loadUrl("<URL_TO_LOAD>")
    }
}

To control when it is necessary to close the Webview, it can be done as follows:

private val myWebViewClient = object : WebViewClient() {
    override fun shouldOverrideUrlLoading(
        view: WebView?,
        request: WebResourceRequest?
    ): Boolean {
        if (request?.url.toString() == "<URL_TO_OBSERVER>") {
            // close here your webview
        }
        return super.shouldOverrideUrlLoading(view, request)
    }
}

To do this, it is necessary to enable permissions in the Android Manifest:

<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-permission android:name="android.permission.CAMERA"/>

Example of how it should look in the app:

It is necessary to have some permissions to function correctly, such as:

  • Camera

  • Geolocation


PreviousMobileNextFlutter

Last updated 1 month ago

Was this helpful?

Still need help?

Didn't find something or still need help? If you're already a client or partner, you can reach out through our .

​
Help Center