I would like to give some more background information on my problem because other users might experience the same problem with iBarcode2 lib.
In some situations Page_Resize event is not raised in my app. In this case also bcsQrCodeReader.Resize is not properly called before actually bcsQrCodeReader.Start is called. If the user does not grant camera permission this leads to an exception in iBarcode2 lib because an assertion failed:
*** Assertion failure in -[MTBBarcodeScanner startScanningWithResultBlock:], /Users/J***/Downloads/iBarcode-2/iBarcode/MTBBarcodeScanner.m:238
The resulting exception message in B4i says:
Scanning is prohibited on this device. Check requestCameraPermissionWithSuccess: method before calling startScanningWithResultBlock:
Therefore I was looking for a solution so call requestCameraPermissionWithSuccess: via NativeObject to make sure camera permission is granted. Meanwhile I learned that requestCameraPermissionWithSuccess: requires a block as parameter that evaluates to true or false.
+ (void)requestCameraPermissionWithSuccess:(void (^)(BOOL success))successBlock { //… }
Therefore I try to define a block in B4i and pass it as Parameter when calling the message. I’m unsure how to process the result. I thought it should work this way:
bl = bl.CreateBlock("successBlock", 1, True)
noScanner.RunMethodWithBlocks("requestCameraPermissionWithSuccess:", Array(bl))
Wait For successBlock_Event(args() As Object)
bolGranted = args(0)
Log(bolGranted)
But actually it even fails before this code is processed with a message not found exception. I also tried to call other operations from MTBBarcodeScanner like:
Method not found: requestCameraPermissionWithSuccess:, target: <MTBBarcodeScanner: 0x281575800>
Also receive this error when I try to call any other methode, like this:
+ (BOOL)scanningIsProhibited { // … }
It is the same error in this case. It says message not found. Can anyone please help?
Thanks,
Thomas