{"title":"Register a device","category":"default","creationDate":1776961627,"content":"<h2 id=\"steps\">Steps<\/h2>\n<ol>\n<li>\n<p>Obtain an <code>ADYDevice<\/code> object through the <code>ADYDeviceRegistry<\/code>, available as a property of the <code>Adyen<\/code> class. <code>ADYDevice<\/code> 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.<\/p>\n<ol>\n<li>\n<p>If you know the name of the device (because you stored in the\u00a0<code>NSUserDefaults<\/code>, for instance) call\u00a0[<code>ADYDeviceRegistry findDeviceByName<\/code>:].<br \/>\nThis returns\u00a0an\u00a0<code>ADYDevice<\/code>, even if a device with the given name is not currently connected. You can then start observing its\u00a0<code>status<\/code>\u00a0property to see if it is connected, and, if not, to be notified when it becomes connected. If it\u00a0<em>is<\/em>\u00a0connected, it is a good idea to keep observing its\u00a0<code>status<\/code>\u00a0since the device might disconnect at any time.<\/p>\n<div class=\"sc-notice note\"><div>\n<p>When a device disconnects, the\u00a0<code>ADYDevice<\/code>\u00a0instance\u00a0remains valid. The\u00a0<code>status<\/code>\u00a0property\u00a0changes\u00a0to\u00a0<code>ADYDeviceStatusGone<\/code>, but when the device becomes connected again at some later point, its status will change back to\u00a0<code>ADYDeviceStatusInitializing<\/code>, and then to\u00a0<code>ADYDeviceStatusInitialized<\/code>.<\/p>\n<\/div><\/div>\n<\/li>\n<li>\n<p>If you do not know the name of the device in advance, you can get access to all currently connected devices using the\u00a0<code>devices<\/code>\u00a0property of the\u00a0<code>ADYDeviceRegistry<\/code>. This is an\u00a0<code>NSMutableArray<\/code>\u00a0that is updated each time a device is connected or disconnected.<\/p>\n<\/li>\n<li>\n<p>For networked devices, you must add the device to the ADYDeviceRegistry. Use <code>addDeviceWithHostname:<\/code>\u00a0and\u00a0<code>removeDeviceWithHostname:<\/code>\u00a0to add Ethernet payment devices to the\u00a0<code>devices<\/code>\u00a0list.<br \/>\nThe 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.<\/p>\n<\/li>\n<\/ol>\n<\/li>\n<li>\n<p>Your app should either choose a device programmatically from the <code>devices<\/code> array (such as always using the first available device), or present a list of devices to the user allowing them to pick one.<\/p>\n<div class=\"sc-notice warning\"><div>\n<p>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.<\/p>\n<\/div><\/div>\n<\/li>\n<\/ol>","url":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/ios-integration\/key-steps-ios\/register-a-device-ios","articleFields":{"id":"31504368","type":"page","_expandable":{"operations":""},"status":"current"},"algolia":{"url":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/ios-integration\/key-steps-ios\/register-a-device-ios","title":"Register a device","content":"Steps\n\n\nObtain an ADYDevice object through the ADYDeviceRegistry, available as a property of the Adyen 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.\n\n\nIf you know the name of the device (because you stored in the\u00a0NSUserDefaults, for instance) call\u00a0[ADYDeviceRegistry findDeviceByName:].\nThis returns\u00a0an\u00a0ADYDevice, even if a device with the given name is not currently connected. You can then start observing its\u00a0status\u00a0property to see if it is connected, and, if not, to be notified when it becomes connected. If it\u00a0is\u00a0connected, it is a good idea to keep observing its\u00a0status\u00a0since the device might disconnect at any time.\n\nWhen a device disconnects, the\u00a0ADYDevice\u00a0instance\u00a0remains valid. The\u00a0status\u00a0property\u00a0changes\u00a0to\u00a0ADYDeviceStatusGone, but when the device becomes connected again at some later point, its status will change back to\u00a0ADYDeviceStatusInitializing, and then to\u00a0ADYDeviceStatusInitialized.\n\n\n\nIf you do not know the name of the device in advance, you can get access to all currently connected devices using the\u00a0devices\u00a0property of the\u00a0ADYDeviceRegistry. This is an\u00a0NSMutableArray\u00a0that is updated each time a device is connected or disconnected.\n\n\nFor networked devices, you must add the device to the ADYDeviceRegistry. Use addDeviceWithHostname:\u00a0and\u00a0removeDeviceWithHostname:\u00a0to add Ethernet payment devices to the\u00a0devices\u00a0list.\nThe 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.\n\n\n\n\nYour 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.\n\nThe 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.\n\n\n","type":"page","locale":"en","boost":14,"hierarchy":{"lvl0":"Home","lvl1":"In-person payments","lvl2":"Deprecation of classic libraries","lvl3":"Library integrations","lvl4":"iOS integration","lvl5":"Key steps","lvl6":"Register a device"},"hierarchy_url":{"lvl0":"https:\/\/docs.adyen.com\/","lvl1":"https:\/\/docs.adyen.com\/point-of-sale","lvl2":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation","lvl3":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation\/classic-library-integrations","lvl4":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/ios-integration","lvl5":"https:\/\/docs.adyen.com\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/ios-integration\/key-steps-ios","lvl6":"\/point-of-sale\/classic-library-deprecation\/classic-library-integrations\/ios-integration\/key-steps-ios\/register-a-device-ios"},"levels":7,"category":"In-person payments","category_color":"green","tags":["Register","device"]}}
