Авторизация для совместного использования следующих типов запрещена: HKCharacteristicTypeIdentifierDateOfBirth в swift ios 8.4

Авторизация для совместного использования следующих типов запрещена: HKCharacteristicTypeIdentifierDateOfBirth, HKCharacteristicTypeIdentifierBiologicalSex в версии swift ios 8.4.

healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToRead, readTypes: healthKitTypesToWrite, completion: { (success, error) -> Void in

                if( completion != nil )
                {
                    completion(success:success,error:error)
                }

            })

Возвращает типы данных, которые Fit хочет записать в HealthKit.

    func dataTypesToWrite() -> NSSet {

        var dietaryCalorieEnergyType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryEnergyConsumed) as HKQuantityType
        var activeEnergyBurnType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned) as HKQuantityType
        var heightType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight) as HKQuantityType
        var weightType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass) as HKQuantityType

        var set = Set([dietaryCalorieEnergyType, activeEnergyBurnType, heightType, weightType])

        return set//[NSSet setWithObjects:dietaryCalorieEnergyType, activeEnergyBurnType, heightType, weightType, nil];
    }

Возвращает типы данных, которые Fit хочет прочитать из HealthKit.

    func dataTypesToRead()->NSSet {
        var dietaryCalorieEnergyType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDietaryEnergyConsumed) as HKQuantityType
        var activeEnergyBurnType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned) as HKQuantityType
        var heightType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight) as HKQuantityType
        var weightType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass) as HKQuantityType
        var birthdayType = HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth) as HKCharacteristicType
        var biologicalSexType = HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex) as HKCharacteristicType

        var set = Set([dietaryCalorieEnergyType, activeEnergyBurnType, heightType, weightType, birthdayType, biologicalSexType])

        return set
    }

person Senthilkumar    schedule 12.08.2015    source источник


Ответы (1)


Аргументы requestAuthorizationToShareTypes меняются местами. Попробуйте это вместо этого:

healthKitStore.requestAuthorizationToShareTypes(healthKitTypesToWrite, readTypes: healthKitTypesToRead, completion: { (success, error) -> Void in

    if( completion != nil )
    {
        completion(success:success,error:error)
    }
})
person Allan    schedule 12.08.2015