Instance Method

addAndSetupAccessories(completionHandler:)

Finds and adds nearby accessories to the home.

Declaration

func addAndSetupAccessories(completionHandler completion: @escaping (Error?) -> Void)

Parameters

completion

The block executed after the request is processed.

error

nil on success; otherwise, error object indicating the reason for failure.

Discussion

This method launches an interactive process that first asks the user to provide a HomeKit code for the accessories—for example, by scanning an 8-digit code, by scanning the QR code, wirelessly by holding an iPhone next to the device, or by manually entering the HomeKit code. The process then asks the user to configure the accessory’s services, naming them and placing them in rooms.

See Also

Managing Accessories

var accessories: [HMAccessory]

The collection of accessories that are part of the home.

func addAndSetupAccessories(with: HMAccessorySetupPayload, completionHandler: ([HMAccessory]?, Error?) -> Void)

Finds and adds nearby accessories to the home using a HomeKit code provided by your app.

class HMAccessory

A home automation accessory, like a garage door opener or a thermostat.