iOS Native Setup


The Arkose Labs Fraud Detection and Prevention Platform (Arkose Labs Platform) needs client-side and server-side setup.

The user initiates processing by logging in to your system. A call is made to the Arkose Labs Server to establish credentials and check identity. An Enforcement Challenge (EC) is displayed if it is considered necessary by the Arkose Labs Platform. The user response to the EC is handled by the client-side. It is then passed to your server-side processing, which then calls the Arkose Labs Verify Endpoint. The response from the Arkose Labs Verify Endpoint is then passed to your server-side processing, which decides what action to take, based on the response.

This guide includes client-side set up information for iOS. The EC is implemented into your iOS app using frameworks that are already part of the Swift programming language.


Fig 1. Flow of information for Arkose Labs Platform

Client-side Setup

Xcode Environment Setup

  1. For this example, you will need to create a directory within your application called Web_Assets. The code in this example is looking for an HTML document called index.html in that directory.



  2. The index.html document must contain the client side EC code which enables the EC to render properly within the WebView.
    The following code is an example of what index.html must contain to invoke a basic EC. In this example, replace "YOUR_PUBLIC_KEY_GOES_HERE" with the Public Key provided by Arkose Labs.

        <script src="" async defer></script>
        <script type="text/javascript">
            function loadChallenge() {
                new ArkoseEnforcement({
                               public_key: "YOUR_PUBLIC_KEY_GOES_HERE",
                               target_html: "CAPTCHA",
                               callback: function() {
        <form method="post" target="_self">
            <p><label for="name">Name</label><input type="text" name="name"></p>
                <div id="CAPTCHA"></div>
                <input name="Submit" type="submit" value="Submit">


Invoking the EC through a ViewController

  1. The following Swift syntax is needed to invoke the EC via the WebView within the app:

import UIKit
import WebKit

// Wrap the WKWebView webview to allow IB use

class MyWebView : WKWebView {
    required init?(coder: NSCoder) {
        let configuration = WKWebViewConfiguration()
        let controller = WKUserContentController()
        configuration.userContentController = controller;
        super.init(frame:, configuration: configuration)

class ViewController: UIViewController {
    @IBOutlet weak var webView: MyWebView!
    override func viewDidLoad() {
        // Choose to load a file or a string
        let loadFile = false
        if let filePath = Bundle.main.path(forResource:"index", ofType:"html", inDirectory: "Web_Assets") {
            if (loadFile) {
                // load file
                let filePathURL = URL.init(fileURLWithPath: filePath)
                let fileDirectoryURL = filePathURL.deletingLastPathComponent()
                webView.loadFileURL(filePathURL, allowingReadAccessTo: fileDirectoryURL)
            } else {
                do {
                    // load html string - baseURL needs to be set for local files to load correctly
                    let html = try String(contentsOfFile: filePath, encoding: .utf8)
                    webView.loadHTMLString(html, baseURL: Bundle.main.resourceURL?.appendingPathComponent("Web_Assets"))
                 } catch {
                     print("Error loading html")

Once the challenge is invoked, you need to collect the Session Token and pass it to your server with the flow data for validation. An example of how to do this in Swift would look like the code below:

let sessionToken = WebView.stringByEvaluatingJavaScriptFromString("document.getElementById('FunCaptcha-Token').value")

Server-Side Instructions

When you have successfully set up the client-side you must go on to the server-side instructions.

Was this article helpful?
0 out of 0 found this helpful