问题
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:
- 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.
- 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. - 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