0

当第一次使用我想要的权限集调用requestAuthorizationToShareTypes:readTypes:completion:时,我可以看到这个模式视图请求用户授权以读取和共享应用程序可能需要访问的每种类型的对象。HKHealthStoreHKQuantityType

我试图弄清楚是否有办法提示用户这个模态视图,除了我第一次打电话:requestAuthorizationToShareTypes:readTypes:completion:

我尝试requestAuthorizationToShareTypes:readTypes:completion:使用相同的集合每次调用,但在第一次调用后它不再提示。在尝试使用不存在的新类型更改集合时,我可以成功提示此屏幕,但我不认为每次使用集合中的新类型调用此方法都是HKQuantityType正确的方法(因为有一个限制类型的数量存在)。

甚至可能吗?

感谢您提供任何帮助。

更新

我将添加一些调用代码片段:

 [self.healthStore  requestAuthorizationToShareTypes:writeDataTypes readTypes:readDataTypes completion:^(BOOL success, NSError *error) {
        if (!success) {
            NSLog(@"You didn't allow HealthKit to access these read/write data types. The error was: %@.", error);
            return;
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            // Update the user interface based on the current user's health information.
        });
    }];

writeDataTypesz和从以下方法返回readDataTypesNSSet

// Returns the types of data that I want to write to HealthKit.
- (NSSet *)dataTypesToWrite
{
    HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
    HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];

    return [NSSet setWithObjects: heightType, weightType, nil];
}

// Returns the types of data that I want to read from HealthKit.
- (NSSet *)dataTypesToRead
{
    HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
    HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
    HKCharacteristicType *birthdayType = [HKCharacteristicType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierDateOfBirth];
    HKCharacteristicType *biologicalSex = [HKCharacteristicType characteristicTypeForIdentifier:HKCharacteristicTypeIdentifierBiologicalSex];
    return [NSSet setWithObjects:heightType,weightType,birthdayType,biologicalSex, nil];
}

每次调用时将集合更改为包含requestAuthorizationToShareTypes:readTypes:completion:类型会导致打开此视图,其中包含我曾经请求权限的所有类型(不一定在此特定调用中): 提示权限时用户看到的视图的屏幕截图

4

2 回答 2

3

按照设计,不可能重新提示用户进行授权。如果您希望用户考虑更改他们对您的应用程序的授权,请让他们转到“设置”或“健康”应用程序来执行此操作。

于 2014-09-12T03:05:55.977 回答
1

暂时我们做不到。但是,能够这样做是有道理的,因为切换访问权限并不像点击“确定”或“取消”按钮那么简单。您可能会认为每个人都知道如何轻按开关并打开电源,但相信我,如果您这么认为,那您就错了。

我会在苹果的雷达中提交一个错误,让他们知道他们的设计并非完美无缺。我们应该能够再次提示用户。如果用户生气,他可以随时删除我们的应用程序,我觉得这比阅读很长的“如何在 Health.app 中启用访问”列表并感到困惑要好得多,这就是普通用户会做的事情。

于 2014-11-03T04:49:37.527 回答