π² 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))
}
}
}
Updated 18 days ago