For: developers. Time to complete: under 60 minutes.

Show Atlas results in your iOS app

You open one URL in a web view and, optionally, listen for three events. There is no SDK, no API key and no user mapping. Atlas handles sign-in inside the surface.

1. The URL

https://<partner>.atlasbiolabs.com/embed

Optional query parameters:

ParameterValuesDefault
langen, dethe device language, falling back to en

2. Open it in a WKWebView

Add a message handler named atlas so the surface can tell your app when something changes.

import WebKit

final class AtlasResultsViewController: UIViewController, WKScriptMessageHandler {
    private let url = URL(string: "https://<partner>.atlasbiolabs.com/embed")!
    private var webView: WKWebView!

    override func viewDidLoad() {
        super.viewDidLoad()
        let config = WKWebViewConfiguration()
        config.userContentController.add(self, name: "atlas")
        webView = WKWebView(frame: view.bounds, configuration: config)
        webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(webView)
        webView.load(URLRequest(url: url))
    }

    func userContentController(_ controller: WKUserContentController,
                               didReceive message: WKScriptMessage) {
        guard let body = message.body as? [String: Any],
              let event = body["event"] as? String else { return }
        switch event {
        case "activated":
            break // the user signed in; you may cache that results exist
        case "results_ready":
            break // show a badge or schedule a local notification
        case "signed_out":
            break // dismiss or return to your own screen
        default:
            break
        }
    }

    deinit {
        webView?.configuration.userContentController.removeScriptMessageHandler(forName: "atlas")
    }
}

SwiftUI: wrap the controller in UIViewControllerRepresentable. Nothing else changes.

3. Sessions

The surface keeps its session in the web view's default data store. The customer enters a code once; the session lasts thirty days and renews silently. Do not clear the web view's data store on sign-out of your own app unless you want the customer to re-enter a code.

4. Test it

Your workspace contains three demo orders — one awaiting a sample, one in the laboratory, one with results. Ask your workspace admin to add your email as a contact on them. Then open the surface, enter your email, enter the code from the email you receive, and you will see all three.

5. Before release

– The surface must not be reachable from a purchase flow inside the app. Ordering links out to Safari. → Ordering and the customer journey

– Do not inject scripts into the surface or modify its content. The surface carries mandatory notices that must render unchanged.

– Do not store the customer's code or forward it anywhere.

That is the integration.

iOS (WKWebView) · Atlas for partners