Add SDK to your project

Using the AR viewer

Permissions

For the viewer to work correctly, 2 usage descriptions should be added to the info.plist file of the project:

  • NSCameraUsageDescription (Privacy - Camera Usage Description)
    This value is required for the ARView to work and should describe the reason for accessing the camera.

  • NSPhotoLibraryUsageDescription (Privacy - Photo Library Usage Description)
    Adding this value is optional but if no reason is supplied the user won’t have the option to save photo’s taken in the ARView to their camera roll

Adding ARViewController

Add a new ViewController to your storyboard and set it’s custom class property to ARViewController.

When showing the ViewController use the assetId property to specify the furniture model you want to show in AR. You can do this in the prepare:for segue function in your calling ViewController:

import UIKit
import FloorplannerARViewer

class ViewController: UIViewController {
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if let vc = segue.destination as? ARViewController {
            vc.assetId = "63fb5e8a8b1a611902d77c642e06215d668b347e"
        }
    }
}

Customizing the ARViewController

Before presenting the ViewController there are some properties that allow to customize the way the AR Viewer looks.

{
    // Set the left button as a reset view button
    vc.leftAction = vc.resetAction

    // Set the right button as a camera button.
    vc.rightButton = vc.cameraAction

    // Set the middle button as a custom addButtonWithTitle
    vc.middleAction = ARViewAction();
    vc.middleAction.title = "Buy"
    vc.middleAction.icon = UIImage(named: "shoppingcart_white");
    vc.middleAction.actionTarget = self;
    vc.middleAction.action = #selector(addToCart(sender:));

    // This will set the background color of the middle button
    vc.view.tintColor = UIColor.red 

    // This will set the color of the plane that's shown to the
    // user to indicate the detected floor
    vc.planeColor = UIColor.green 
}

@objc func addToCart(sender: ARViewController) {
    // implementation
}