In HomeKit, can I set the code that enables the accessory programmatically?

别来无恙 提交于 2019-12-24 11:52:41

问题


I would like to know if you can set the code that enables the accessory programmatically? I in this moment use:

import UIKit
import Foundation
import HomeKit

let homeManager = HMHomeManager()

func addAccessory () {

 if let home = homeManager.primaryHome {

        for room in home.rooms {

        if room.name == "Kitchen" {

  homeManager.primaryHome?.addAccessory(accessory, completionHandler: { (error) -> Void in
                  if error != nil {
                        print("ERROR 1 \(error?.localizedDescription)")
                    }else {
         self.homeManager.primaryHome?.assignAccessory(accessory, toRoom: room, completionHandler: { (error) -> Void in
                 if error != nil {
                    print("ERROR 2 \(error?.localizedDescription)")
                            } else {
                                print("Accessory Add successfully")

      }}}}
   }

I would not use the usual view offered by Apple to enter the code.


回答1:


At this point in time, there is no reference in HomeKit documentation to being able to override the default screens that are displayed when using the HMHome addAccessory method.

I was looking for this myself and have not found anything and have also posed the question on the Apple Developer's HomeKit forum. If I hear differently on the forums, I'll post back here.



来源:https://stackoverflow.com/questions/35984988/in-homekit-can-i-set-the-code-that-enables-the-accessory-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!