Open HomeKits X-HM:// URL sheme

∥☆過路亽.° 提交于 2020-06-27 16:35:19

问题


I'm creating an App with the HomeKit SDK and I'd like to add an uncertified accessory programmatically. My goal is to build a user-friendly and convenient pairing process without having a printed QR-code or NFC ready accessory. I'd like to hand on the pairing pin / pairing URL programmatically, so the user doesn't need to worry about any codes.

I've already set up the HMAccessoryBrowser and it finds the accessory fast and reliable. So far I've the HMAccessory object as well as a valid pairing link (example: X-HM://123456789ABC) and I've tried three ways, in order to add the accessory:

  1. Generate a QR-Code with the Url and scan it with the native Camera or Home App, which works very well. - Problem: You need a second device / print the QR code to scan the QR code.
  2. Use HMHome's addAccessory function to add the HMAccessory directly. - Problem: After accepting the prompt asking to add the device, the Home App opens and asks to scan the QR code or to choose the device manually and enter the code. This doesn't make sense for me, unless I've just told HomeKit which accessory it should add but it's also doing this behavior with accessories of the HomeKit Accessory Simulator and also mentioned in this post.
  3. Open the X-HM URL with UIApplication.open(). - Problem: Also with HomeKit permissions, the function fails with the error message:

-canOpenURL: failed for URL: "X-HM://123456789ABC" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

Before granting access to my Home Data, the error message was something like, you do not have the permission to open this url.

In my opinion the direct opening of the pairing URL seems to be the best solution unless it's the same process for the user like adding any other HomeKit device without the need to scan a QR code, but I'm running out of ideas.

I'd appreciate any idea, workaround or other process, to get this thing paired, thanks in advance!

来源:https://stackoverflow.com/questions/48912759/open-homekits-x-hm-url-sheme

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