Integrate BitLabs using WebView

This article shows you how to integrate our Offer Wall on any platform (iOS, Android, Unity) and on websites.

1. Get your API Key

Sign up for a new developer account and create a new App. Copy your App Token to initiate the SDK.

Server-to-Server Callbacks

On the dashboard, you can also set up your callbacks. Learn how to set them up in our server-to-server callback guide.

For Websites: Open BitLabs URL in a new tab

The Offer Wall will open in their browser where they can complete surveys in exchange for your virtual currency.

Open https://web.bitlabs.ai/?uid=[UUID]&token=[YOUR_API_TOKEN]

JavaScript Example:
window.open('https://web.bitlabs.ai/?uid=test1234&token=5fec306d-039a-41f3-94be-56ae3e74b41f', '_blank');

Android Example:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://web.bitlabs.ai/?uid=test1234&token=5fec306d-039a-41f3-94be-56ae3e74b41f")));

iOS Swift Example:
UIApplication.sharedApplication().openURL(NSURL(string:"https://web.bitlabs.ai/?uid=test1234&token=5fec306d-039a-41f3-94be-56ae3e74b41f")!)

Embed the URL in a WebView on iOS

If you would like the user to take the survey in a native iOS app, please embed the URL in a WebView.

If you are unfamiliar with WebViews, you can find more on that in Apple’s official documentation on that.

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
    
    var webView: WKWebView!
    
    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        webView = WKWebView(frame: .zero, configuration: webConfiguration)
        webView.uiDelegate = self
        view = webView
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let myURL = URL(string:"https://web.bitlabs.ai/?uid=[UUID]&token=[YOUR_API_TOKEN]")
        let myRequest = URLRequest(url: myURL!)
        webView.load(myRequest)
    }}

Embed URL in Webview on Android

If you would like the user to take the survey in a native Android app, please embed the URL in a WebView.

If you are unfamiliar with WebViews, you can find more on that in Google’s official documentation on that.

WebView myWebView = new WebView(activityContext);
setContentView(myWebView);
// Enable JavaScript to support all kinds of Surveys
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
// Load the OfferWall URL with your token included
myWebView.loadUrl("https://web.bitlabs.ai/?uid=[UUID]&token=[YOUR_API_TOKEN]");