Steps
-
Obtain an
ADYDevice
object through theADYDeviceRegistry
, available as a property of theAdyen
class.ADYDevice
is a representation of a terminal connected by Bluetooth, 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 [ADYDeviceRegistry findDeviceByName
:].
This returns anADYDevice
, even if a device with the given name is not currently connected. You can then start observing itsstatus
property to see if it is connected, and, if not, to be notified when it becomes connected. If it is connected, it is a good idea to keep observing itsstatus
since the device might disconnect at any time.When a device disconnects, the
ADYDevice
instance remains valid. Thestatus
property changes toADYDeviceStatusGone
, but when the device becomes connected again at some later point, its status will change back toADYDeviceStatusInitializing
, and then toADYDeviceStatusInitialized
. -
If you don't know the name of the device in advance, you can get access to all currently connected devices using the
devices
property of theADYDeviceRegistry
. This is anNSMutableArray
that is updated each time a device is connected or disconnected. -
For networked devices, you must add the device to the ADYDeviceRegistry. Use
addDeviceWithHostname:
andremoveDeviceWithHostname:
to add Ethernet payment devices to thedevices
list.
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
devices
array (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.