Bug(s) or Feature(s)

Getting Started with IOS


Installation

As previously described the react-native-bluetooth-classic is installed through NPM:

$ npm install react-native-bluetooth-classic --save

Once installed autolinking will take over and all that is required is starting the application as normal. Be sure to check out the previous link if you need to customize or disable the autolinking of this (or any) module.

MFi Protocols

Remember to make sure you have your protocol strings provided within your application plist file - this is a requirement of the External Accessory framework. This is the top cause of:

Unhandled JS Exception: TypeError: Cannot read property 'xxx' of undefined

while attempting to use the library. An example of what this looks like in your own plist file is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>UISupportedExternalAccessoryProtocols</key>
  <array>
    <string>com.apple.m1</string>
  </array>
</dict>
</plist>

There are also a number of other IOS security related items that are required:

<key>NSBluetoothAlwaysUsageDescription</key>
	<string>Access bluetooth device over serial connection to document connection features</string>

F.A.Q

Why isn't my protocol working?

Remember these are MFi protocols, they are not communication protocols. This is the primary reason or issue that gets asked with regards to IOS, the example above com.apple.m1 is not a real protocol and will not provide you with access to devices.

Where do I get MFi protocols?

You either need to find the protocols listed on the companies website (Zebra for example has some posted) but in most cases these are kept super secret; like Fight Club secret!

Getting devices MFi compliant costs companies a boat load of money, so they don't generally give these out for free. You'll need to work with a vendor constantly (as you'll find there are some super annoying things to do for releasing).

I Can See my Device in Bluetooth Screen

The IOS Bluetooth screen will always display your devices. The MFi layer that provides the functionality ExternalAccessory library is where the issue is. You need to provide a valid set of protocol strings that match your devices MFi compliance in order to get access to them in your app.

How to I change Encoding?

The default connection uses https://developer.apple.com/documentation/corefoundation/cfstringbuiltinencodings values when setting DEVICE_ENCODING during connection.