diff --git a/package-lock.json b/package-lock.json index 08e5651..b698f2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta2", + "version": "1.0.0-beta3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta2", + "version": "1.0.0-beta3", "license": "ISC" } } diff --git a/package.json b/package.json index 204cb2e..04129a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@spoonconsulting/cordova-plugin-roomplan", - "version": "1.0.0-beta2", + "version": "1.0.0-beta3", "description": "", "main": "index.js", "scripts": { diff --git a/plugin.xml b/plugin.xml index 7c780cf..c4df11d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -14,6 +14,7 @@ - + + \ No newline at end of file diff --git a/src/ios/CDVRoomPlan.swift b/src/ios/CDVRoomPlan.swift index e079d14..844a304 100644 --- a/src/ios/CDVRoomPlan.swift +++ b/src/ios/CDVRoomPlan.swift @@ -72,7 +72,6 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat self.activityIndicator?.stopAnimating() } - // Action for the 'Done' button @objc func doneScanning(_ sender: UIButton) { if state == "scanning" { stopSession() @@ -104,9 +103,9 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat let jsonData = try jsonEncoder.encode(finalResults) try jsonData.write(to: jsonFile) try finalResults?.export(to: usdzFile, exportOptions: .parametric) - if finalResults != nil { + if (finalResults != nil) && isCapturedRoomNil(capturedRoom: finalResults!) { let result = ["usdz": usdzFile.absoluteString, "json": jsonFile.absoluteString, "message": "Scanning completed successfully"] - let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: usdzFile.absoluteString) + let pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result) pluginResult?.keepCallback = true self.commandDelegate.send(pluginResult, callbackId: self.command.callbackId) } @@ -154,4 +153,12 @@ class CDVRoomPlan: CDVPlugin, RoomCaptureSessionDelegate, RoomCaptureViewDelegat button.translatesAutoresizingMaskIntoConstraints = false return button } + + func isCapturedRoomNil(capturedRoom: CapturedRoom) -> Bool { + if #available(iOS 17.0, *) { + return capturedRoom.walls.count != 0 || capturedRoom.doors.count != 0 || capturedRoom.windows.count != 0 || capturedRoom.sections.count != 0 || capturedRoom.floors.count != 0 || capturedRoom.objects.count != 0 || capturedRoom.openings.count != 0 + } else { + return false + } + } }