- Obtain an
ADYDeviceobject through the
ADYDeviceRegistry, available as a property of the
ADYDeviceis a representation of a terminal connected by Bluethooth, Lightning port or Ethernet. It is possible that multiple devices are connected at the same time, and a device may become connected or disconnected at any time.
If you know the name of the device (because you stored in the
NSUserDefaults, for instance) call [
This returns an
ADYDevice, even if a device with the given name is not currently connected. You can then start observing its
statusproperty to see if it is connected, and, if not, to be notified when it becomes connected. If it is connected, it’s a good idea to keep observing its
statussince the device might disconnect at any time.
When a device disconnects, the
ADYDeviceinstance remains valid. The
statusproperty changes to
ADYDeviceStatusGone, but when the device becomes connected again at some later point, its status will change back to
ADYDeviceStatusInitializing, and then to
- If you don’t know the name of the device in advance, you can get access to all currently connected devices using the
devicesproperty of the
ADYDeviceRegistry. This is an
NSMutableArraythat is updated each time a device is connected or disconnected.
- For networked devices, you must add the device to the ADYDeviceRegistry. Use
removeDeviceWithHostname:to add ethernet payment devices to the
The registry attempts to connect to the device until it is online. Ethernet devices and Lightning devices go through the same states as Bluetooth devices. The main difference is that an ethernet device attempts to connect to the device until it is online and is always in the devices array, even if it is not connected.
Your app should either choose a device programmatically from the
devicesarray (such as always using the first available device), or present a list of devices to the user allowing them to pick one.
The contents of the devices array can change at any time when devices connect or disconnect. Either make a copy of the array before using it, or use key-value observing on the array to notify the app when devices connect or disconnect and present live information about connected devices.