> For the complete documentation index, see [llms.txt](https://docs.tutar.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tutar.app/embedding/native-ios.md).

# Native iOS

Embedding TutAR 3D viewer in a native iOS app

## Prerequisites

* This guide expects basic [iOS development](https://developer.apple.com/documentation/) knowledge with kotlin
* Get a Connect3D Vendor Account from TutAR by sending a mail at <mark style="color:orange;"><<email@tutar.app>></mark>.
* Generate an API key from the [Connect3D dashboard](https://connect3d.tutar.app/dashboard)

## Getting User Permissions

The AR functionality in the viewer requires Camera access, Make sure to take camera permission from the user.&#x20;

{% code title="info.plist" %}

```xml
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to your Camera.</string>
```

{% endcode %}

## Add Embedding&#x20;

Refer the below example implementation using the native `WKWebView`

<pre class="language-swift" data-title="ContentView.swift"><code class="lang-swift">// Example Implementation

import SwiftUI
import WebKit

struct WebView: UIViewRepresentable {
    let url: URL?
    
    func makeUIView(context: Context) -> WKWebView {
        let preference = WKWebpagePreferences();
        preference.allowsContentJavaScript = true
        
        let configuration = WKWebViewConfiguration()
        configuration.defaultWebpagePreferences = preference
        configuration.allowsInlineMediaPlayback = true
        
        let webView = WKWebView(frame: .zero, configuration: configuration)
        webView.uiDelegate = context.coordinator

       return webView
    }
    
    func updateUIView(_ uiView: WKWebView, context: Context) {
        guard let _url = url else { return }
        let request = URLRequest(url: _url)
        uiView.load(request)
    }
    
    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }
    
    class Coordinator: NSObject, WKUIDelegate {
        var parent: WebView

        init(_ parent: WebView) {
            self.parent = parent
        }

        func webView(
            _ webView: WKWebView,
            requestMediaCapturePermissionFor origin: WKSecurityOrigin,
            initiatedByFrame frame: WKFrameInfo,
            type: WKMediaCaptureType,
            decisionHandler: @escaping (WKPermissionDecision) -> Void
        ) {

            decisionHandler(.grant)
        }
    }
}

struct ContentView: View {
    var body: some View {
        NavigationView {
            WebView(url: URL(string: "https://web.tutar.app?api-key=&#x3C;<a data-footnote-ref href="#user-content-fn-1">API-KEY</a>>&#x26;user-id=&#x3C;<a data-footnote-ref href="#user-content-fn-2">USER-ID</a>>"))
                .navigationTitle("TutAR - WKWebView")
        }
    }
}


#Preview {
    ContentView()
}
</code></pre>

[^1]: The key generated from the connect3D dashboad

[^2]: A unique id to distinguish each users. this can be the primary id of the logged in user in your platform.
