Forum Xamarin.iOS

Build custom Keyboard with barcode scanner

MohammadBraeiMohammadBraei DEUniversity
edited September 2015 in Xamarin.iOS

In Android there is a custom keyboard with a button which runs the barcode scanner. I wanted to build the same keyboard for IOS.
For barcode scanning I am using ZXing, which is really straightforward. Running the scanner with this library just needs three lines of code.
Then I wanted to build a custom keyboard and for that I am using the sample of Xamarin SingleWordKeyboard which is working fine. So I have the two components which work fine separately. In the SingleWordKeyboard Sample there is the main event for the button: mainButton.TouchUpInside .
Here I inserted my code for the scanner:
var scanner = new ZXing.Mobile.MobileBarcodeScanner();
var result = await scanner.Scan();

    TextDocumentProxy.InsertText (result.Text);` 

But when I run the sample, and click on the button on the keyboard, I see the following error in the output window:
2015-09-16 17:36:32.980 SingleWordKeyboard[6000:1720579] plugin com.your-company.SingleWordKeyboard.KeyboardExtension interrupted
2015-09-16 17:36:32.981 SingleWordKeyboard[6000:1723847] plugin com.your-company.SingleWordKeyboard.KeyboardExtension invalidated
2015-09-16 17:36:34.082 SingleWordKeyboard[6000:1720411] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x787797a0 {Message=Service Connection Interrupted}
Why do I get the following bug? What is wrong with the code?

Sign In or Register to comment.