iOS
We provide Swift SDK distributed by CocoaPods for your iOS apps to present AR-sessions, easily.
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
-
Import
Meshkraft
framework header in yourAppDelegate
import Meshkraft
-
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.
Code Implementation
Import Meshkraft
framework header
import Meshkraft
AR Session
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()
}
}
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 ?? "")")
})
Device Support
You can check if AR is supported on the device:
Meshkraft.isARSupported()