How do I implement the Linea Pro SDK when building an app with SwiftUI that has no AppDelegate and no ViewController?
I integrated the SDK as described here How do I use the Linea-Pro SDK for IOS? and I used the DTDevices.h and libdtdev.a files that can be found here https://github.com/matheuscmpm/lineaswift.
Now the class I wrote to try and work with the SDK looks something like this:
import Foundation
class LineaDevice: DTDeviceDelegate {
private let oScanner: DTDevices
init() {
self.oScanner = DTDevices()
self.oScanner.delegate = self
self.oScanner.connect()
}
func barcodeData(barcode: String!, type: Int32) {
print("Barcode: \(barcode!)")
}
public func getConnectionState() -> Int32 {
return self.oScanner.connstate
}
}
In the global scope, right above @main
, I initialize this class like so: let oLineaScanner = LineaDevice()
.
So far, so good. The method oLineaScanner.getConnectionState()
returns 2
, which means the iOS device successfully connects to the scanner and when I scan a barcode, the device beeps.
However, the method barcodeData
- which I assumed should now be getting called by the SDK - does not get called.
Any documentation I could find so far assumes that there is an AppDelegate and a ViewController, which doesn't exist in my SwiftUI project. I assume that that's the issue here. I am relatively new to developing for iOS so I am kinda clueless on how to proceed from this point on.
Is there any way I can make it work like this and if not then how do I make it work?