Skip to main content

iOS

We provide Swift SDK distributed by CocoaPods for your iOS apps to present AR-sessions, easily.

Version License Platform

Installation

To integrate Meshkraft into your Xcode project using CocoaPods, add it to your Podfile:

pod 'Meshkraft'

Then, run the following command:

$ pod install

Usage

Initialization

  1. Import Meshkraft framework header in your AppDelegate

    import Meshkraft
  2. Add the following to your AppDelegate application:didFinishLaunchingWithOptions: method.

    Meshkraft.setApiKey("YOUR_API_KEY")

    Make sure to replace YOUR_API_KEY with your application token.

AR Session

Import Meshkraft framework header

import Meshkraft

Start an AR session with product SKU:

Meshkraft.meshkraft().startARSession(productSKU: "YOUR_PRODUCT_SKU")

To receive model loading status notifications , conform to MeshkraftDelegate protocol:

Meshkraft.meshkraft().delegate = self
extension ViewController : MeshkraftDelegate {

func modelLoadStarted() {
print("load started")
activityIndicator.startAnimating()
}

func modelLoadFinished() {
print("load finished")
activityIndicator.stopAnimating()
}

func modelLoadFailed(message: String) {
print("load failed message: \(message)")
activityIndicator.stopAnimating()
}

}

VTO Session

Start a VTO session with product SKU:

Meshkraft.meshkraft().startVTOSession(productSKU: "YOUR_PRODUCT_SKU")

The VTO session requires camera access, so make sure to add the necessary permissions to your Info.plist file. Add the following keys with their respective descriptions:

<key>NSCameraUsageDescription</key>
<string>Your description for why the app needs camera access.</string>

Replace "Your description for why the app needs camera access." with a suitable explanation for your users.

Check Device Support

You can check if AR is supported on the device:

Meshkraft.isARSupported()

Model URL

Get AR model URL with product SKU: Get the modelURL from the completion block, check the errorMessage for any possible errors.

Meshkraft.meshkraft().getModelURL(productSKU: "YOUR_PRODUCT_SKU", completion: {(modelUrl, errorMessage) in
print("modelUrl: \(modelUrl ?? "")")
print("errorMessage: \(errorMessage ?? "")")
})