iosxamarinxamarin.ioshomekit

Xamarin iOS - HomeKit integration


I'm working on an app using Xamarin.iOS. I need to add the possibility to add an accessory to HomeKit using the address coming from an internal API (basically I retrieve the address of the device using a web request). Once I have this setupCode of the accessory I try to use the following API from HomeKit

https://learn.microsoft.com/en-us/dotnet/api/homekit.hmhome.addandsetupaccessories?view=xamarin-ios-sdk-12#HomeKit_HMHome_AddAndSetupAccessories_HomeKit_HMAccessorySetupPayload_System_Action_HomeKit_HMAccessory___Foundation_NSError__

in particular the API with the following signature AddAndSetupAccessories(HMAccessorySetupPayload, Action<HMAccessory[],NSError>) but the Action that should be called on completion it's never called.

The only result that I get is that my app tries to go in background but it remain stuck and become unusable.

The only hint that I get from the device log is this:

HomeUIService Host app does not have entitlement 'com.apple.homekit.private-spi-access' or 'com.apple.developer.homekit.allow-setup-payload' -- not allowed to add from URL!

but I have the Entitlement for Homekit added to my app. I'm not able to find any documentation on the entitlements specified in the log message.

Has anyone experienced something like this?

Thank you guys


Solution

  • I had the answer from Apple Support, so I answer my question just for someone in the future or myself in the past (Dark series spoiler :).

    Basically this API doesn't work if you don't add the Entitlement "com.apple.developer.homekit.allow-setup-payload" with value equals to True.

    I know, there is no documentation regarding this, but this is it.

    Cheers guys