diff --git a/package-lock.json b/package-lock.json index 71087d5..24cd1be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta5", + "version": "1.0.0-beta6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta5", + "version": "1.0.0-beta6", "license": "ISC" } } diff --git a/package.json b/package.json index 709ee57..6a3425e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta5", + "version": "1.0.0-beta6", "description": "", "main": "index.js", "scripts": { diff --git a/src/ios/CDVRoomPlan.swift b/src/ios/CDVRoomPlan.swift index a04198f..ddd7cd0 100644 --- a/src/ios/CDVRoomPlan.swift +++ b/src/ios/CDVRoomPlan.swift @@ -8,6 +8,7 @@ import Foundation import UIKit import RoomPlan +import ARKit @objc(CDVRoomPlan) class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegate, UIDocumentPickerDelegate { @@ -34,8 +35,8 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat super.init() } - @objc(openRoomPlan:) - func openRoomPlan(command: CDVInvokedUrlCommand) { + @objc(open:) + func open(command: CDVInvokedUrlCommand) { self.command = command roomCaptureView = RoomCaptureView(frame: viewController.view.bounds) roomCaptureView.captureSession.delegate = self @@ -48,9 +49,17 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat roomCaptureView.bottomAnchor.constraint(equalTo: viewController.view.bottomAnchor), roomCaptureView.rightAnchor.constraint(equalTo: viewController.view.rightAnchor) ]); + NotificationCenter.default.addObserver(self, selector: #selector(cancelScanning), name: UIApplication.willResignActiveNotification, object: nil) startSession() } + @objc(isSupported:) + func isSupported(command: CDVInvokedUrlCommand) { + let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: ARWorldTrackingConfiguration.supportsSceneReconstruction(.mesh)) + pluginResult?.keepCallback = true + self.commandDelegate.send(pluginResult, callbackId: command.callbackId) + } + private func startSession() { state = "scanning" roomCaptureView?.captureSession.run(configuration: roomCaptureSessionConfig) @@ -94,6 +103,7 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat self.activityIndicator?.stopAnimating() stopSession() roomCaptureView.removeFromSuperview() + NotificationCenter.default.removeObserver(self) let result = ["message": "Scanning cancelled"] let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result) pluginResult?.keepCallback = true diff --git a/www/CDVRoomPlan.js b/www/CDVRoomPlan.js index ec56584..10cee8b 100644 --- a/www/CDVRoomPlan.js +++ b/www/CDVRoomPlan.js @@ -1,6 +1,11 @@ -var exec = require('cordova/exec'); +var exec = require("cordova/exec"); -exports.openRoomPlan = function(success, error) { - console.log("CDVRoomPlan.js: openRoomPlan"); - exec(success, error, "CDVRoomPlan", "openRoomPlan", []); - }; +exports.open = function (success, error) { + console.log("CDVRoomPlan.js: open"); + exec(success, error, "CDVRoomPlan", "open", []); +}; + +exports.isSupported = function (success, error) { + console.log("CDVRoomPlan.js: isSupported"); + exec(success, error, "CDVRoomPlan", "isSupported", []); +}