0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Xcode11でのHealthKitのPrivacyPolicy設定 for Apple Watch

Posted at

いつものように開発で引っかかったところのメモです。

環境

  • Xcode 11.3 (11C29)
  • iOS 13.3
  • watchOS 6.1.1

今までは

healthStore_ = [[HKHealthStore alloc] init];
HKQuantityType *type = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
HKQuantityType *type2 = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
HKQuantityType *type3 = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned];

[healthStore_ requestAuthorizationToShareTypes:nil readTypes:[NSSet setWithObjects:type, type2, type3, nil] completion:^(BOOL success, NSError * _Nullable error) {
    
    if (success) {
    NSLog(@"health data request success");
    
    }else{
    NSLog(@"error %@", error);
    }
}];

という感じでWorkout Sessionの為のHKHealthStore を準備できたのですが、Xcode11になってから、

  • NSHealthShareUsageDescription
  • NSHealthUpdateUsageDescription

をinfo.plistに設定していて、かつ、ちゃんとdescriptionを(エンタープライズアプリであろうと)書いてあげないと、watchアプリがクラッシュするようになりました。

watchアプリやってる人少ないんでしょうけど、、、気をつけましょうね。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?