Xamarin IOS程序:未显示HealthKit用户权限对话框
我遵循教程在这里一个href =“ https://github.com/xamarin/ios-samples/tree/main/main/ios8/introtohealthkit” rel =“ nofollow noreferrer”>在这里)用于Xamarin构建的第一个ios Health-kit应用程序,但权限对话框未显示在用户的尽头。这两个关键字nshealthshareuusagedescription和nshealthupdateusagedesscription in info.plist中。询问权限的代码是,
private void ValidateAuthorization ()
{
//Request / Validate that the app has permission to store heart-rate data
var heartRateId = HKQuantityTypeIdentifierKey.HeartRate;
var heartRateType = HKObjectType.GetQuantityType (heartRateId);
var typesToWrite = new NSSet (new [] { heartRateType });
//We aren't reading any data for this sample
var typesToRead = new NSSet ();
healthKitStore.RequestAuthorizationToShare (
typesToWrite,
typesToRead,
ReactToHealthCarePermissions);
}
如果我在iOS模拟器上运行该应用程序,则输出报告“丢失com.apple.developer.healthkit Afterlement”错误。 我已经在witslement.plist文件中启用了HealthKit许可,并相应地选择了该选项。
hkwork [935:10236] [默认]连接错误:错误 域= com.apple.healthkit代码= 4“缺失 com.apple.developer.healthkit权利。” userInfo = {nslocalizedDescription =缺少com.apple.developer.healthkit 权利。}线程开始:#2 HKWORK [935:10236] [auth]失败 确定授权状态:错误域= com.apple.healthkit 代码= 4“缺少com.apple.developer.healthkit权利。” userInfo = {nslocalizedDescription =缺少com.apple.developer.healthkit 权利。} HKWORK [935:10241] [插件] AddinstanceForFactory:否 工厂注册ID< cfuuid 0x60000167c9a0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
将不胜感激。
I follow the tutorial here (Code from Git Code repo here) for Xamarin building the first ios health-kit app but the permission dialog is not shown in the user's end. Both keywords NSHealthShareUsageDescription and NSHealthUpdateUsageDescription are in the info.plist. The code asking permission is
private void ValidateAuthorization ()
{
//Request / Validate that the app has permission to store heart-rate data
var heartRateId = HKQuantityTypeIdentifierKey.HeartRate;
var heartRateType = HKObjectType.GetQuantityType (heartRateId);
var typesToWrite = new NSSet (new [] { heartRateType });
//We aren't reading any data for this sample
var typesToRead = new NSSet ();
healthKitStore.RequestAuthorizationToShare (
typesToWrite,
typesToRead,
ReactToHealthCarePermissions);
}
If I run the app on iOS simulator, the output reports "Missing com.apple.developer.healthkit entitlement" error.
I have enabled the HealthKit permission in the Entitlements.plist file and selected the option accordingly.
HKWork[935:10236] [default] connection error: Error
Domain=com.apple.healthkit Code=4 "Missing
com.apple.developer.healthkit entitlement."
UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit
entitlement.} Thread started: #2 HKWork[935:10236] [auth] Failed to
determine authorization status: Error Domain=com.apple.healthkit
Code=4 "Missing com.apple.developer.healthkit entitlement."
UserInfo={NSLocalizedDescription=Missing com.apple.developer.healthkit
entitlement.} HKWork[935:10241] [plugin] AddInstanceForFactory: No
factory registered for id <CFUUID 0x60000167c9a0>
F8BB1C28-BAE8-11D6-9C31-00039315CD46
Any amount of help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现自己的问题是:在项目选项 - &gt; ios捆绑签名时,我需要配置iPhoneSimulator的平台和iPhone的平台(选择下拉菜单以配置两者)。签名身份和配置配置文件都不能自动。自定义权利需要包括protlemets.plist。我没有设置在iPhone的平台下。此更改使在iPhone上模拟时可以弹出权限页面,但不能在模拟器上进行弹出。
同时,在“权利”中,使HealthKit的能力可能会改变“ com.apple.apple.developer.healthkit”的价值。这可能是Visual Studio中的一个错误,只是不要手动将值重新更改回去,因为这将禁用HealthKit功能。
I found my problem is: at Project Options->iOS Bundle signing, I need to configure both the platform of iPhoneSimulator and the platform of iPhone (select the dropdown menu to configure both). Both the signing identity and provisioning profile can't be automatic. The custom Entitlements needs to include Entitlemets.plist. I didn't set under the platform of iPhone. This change enables poping up permission page when simulating on iPhone, but not on the simulator.
Meanwhile, in Entitlement.pList, enabling capability of HealthKit might change the value of the key "com.apple.developer.healthkit". This might be a bug in Visual Studio and just don't manually change the value back because that will disable the healthkit capability.