๐ฒ Android/iOS Integration
Android
To add Transak to you Android app add the below code:
MainActivity.Java
Make sure to add your API key and customise using query parameters.
import android.webkit.WebView;
...
webView = (WebView) findViewById(R.id.transakWidget);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("https://global-stg.transak.com?apiKey=<YOUR_API_KEY>&<QUERY_PARAMETERS>");
Activity_main.xml
<WebView xmlns:android="<http://schemas.android.com/apk/res/android>"
android:id="@+id/transakWidget"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Provide permission in AndroidManifest.XML
<uses-permission android:name="android.permission.INTERNET"/>
iOS
You can add the Transak widget to your iOS app using the below code.
Make sure to add your API key and customise using query parameters.
import UIKit
import WebKit
class WebViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
@IBOutlet weak var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string: "https://global-stg.transak.com?apiKey=<YOUR_API_KEY>&<QUERY_PARAMETERS>")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if let serverTrust = challenge.protectionSpace.serverTrust {
completionHandler(.useCredential, URLCredential(trust: serverTrust))
}
}
}
Implement code "ui.webview.settings.domStorageEnabled = true" for native integration in Android/iOS.
This code enables DOM storage in the WebView, allowing web applications to store data using the DOM Storage API.
Flutter
As of today, we do not provide support for the Flutter framework.
Updated over 1 year ago