0
私のアプリケーションは、ユーザーがHealthkitへのアクセスを許可できるHealthKitの権限画面を開いていません。 私の時計に、自分のアプリが「あなたの健康データにアクセスしたい」という画面が表示されます。しかし、電話機は設定を呼び出す代わりにアプリの起動画面と最初のページに移動するだけです。エラーはありません。アプリは下記のコードで認証をリクエストしています。何か案は?HealthKitのアクセス権が開けません
import UIKit
import WatchConnectivity
import HealthKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, WCSessionDelegate {
var window: UIWindow?
let healthStore = HKHealthStore()
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
WatchSessionManager.sharedManager.startSession()
return true
}
// authorization from watch
func applicationShouldRequestHealthAuthorization(application: UIApplication) {
let healthStore = HKHealthStore()
let quantityType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)
let calorieQuantityType = HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)
let dataTypesToRead = NSSet(objects: HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate)!, HKQuantityType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned)!)
healthStore.requestAuthorizationToShareTypes(nil, readTypes: dataTypesToRead as! Set<HKObjectType>, completion: { (success, error) in
if success {
} else {
print(error!.description)
}
})
healthStore.handleAuthorizationForExtensionWithCompletion { success, error in
}
}