4

I am working on an iPad application which uses Motorola CS3070 bar code scanner. I am connecting the scanner as using HID Profile and it is treated as a bluetooth keyboard by iPad. When scanner is connected to iPad using bluetooth and if we focus on any text field inside application, it won't open device virtual keyboard. This is expected as device treats bar code scanner as bluetooth keyboard.

While doing scanning if the scanner is disconnected, device virtual keyboard will be displayed. What I want is, when scanner is disconnected, I need to get that information from some event and show a popup/alert to user that scanner is disconnected. I think if there is a way to know when device virtual keyboard is displayed or application is using bluetooth keyboard we can use that information to show the popup.

Please let me know if it is possible or any other suggestion which I can try.

Thanks in advance.

zk_mars
  • 1,339
  • 2
  • 15
  • 36
Shyju
  • 208
  • 3
  • 9

1 Answers1

2

An indirect and SDK-safe way is to make a text field a first responder. If the external keyboard is present, the UIKeyboardWillShowNotification local notification shall not be posted.

You can listen to the "GSEventHardwareKeyboardAttached"(kGSEventHardwareKeyboardAvailabilityChangedNotification) Darwin notification, but this is a private API, so it's possible your app will get rejected if you use this. To check if the external hardware is present, use the private GSEventIsHardwareKeyboardAttached() function.

UIKit listens to this and sets the UIKeyboardImpl.isInHardwareKeyboardMode property accordingly, but again this is private API.

I got this answer from here.

Community
  • 1
  • 1
Nithin Michael
  • 2,166
  • 11
  • 32
  • 56