在HomeKit中,我可以设置以编程方式启用附件的代码吗? [英] In HomeKit, can I set the code that enables the accessory programmatically?

查看:184
本文介绍了在HomeKit中,我可以设置以编程方式启用附件的代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以设置以编程方式启用附件的代码?我在此刻使用:

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")

      }}}}
   }

我不会使用Apple提供的常用视图来输入代码.

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

推荐答案

目前,在HomeKit文档中没有提及能够覆盖使用HMHome addAccessory方法时显示的默认屏幕.

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.

我本人正在寻找此消息,但未找到任何内容,并且还在Apple Developer的HomeKit论坛上提出了问题.如果我在论坛上听到的声音不同,我会在这里发帖.

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.

这篇关于在HomeKit中,我可以设置以编程方式启用附件的代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆