如何獲取系統健康程式的許可權和資訊

2021-07-13 17:22:34 字數 1758 閱讀 9426

1.首先,我們需要在xcode 中設定healthkit的開關

2.在需要獲取健康資訊的地方匯入# import

@inte***ceviewcontroller ()

@property(nonatomic, strong) hkhealthstore *healthstore;

@end

在- (void)viewdidload中獲取許可權

- (void)viewdidload

//建立healthstore例項物件

self.healthstore = [[hkhealthstore alloc] init];

//設定需要獲取的許可權這裡僅設定了步數

hkobjecttype *stepcount = [hkobjecttype quantitytypeforidentifier:hkquantitytypeidentifierstepcount];

nsset*healthset = [nssetsetwithobjects:stepcount,nil];

//從健康應用中獲取許可權

[self.healthstore requestauthorizationtosharetypes:nilreadtypes:healthset completion:^(boolsuccess,nserror* _nullable error)

else

}];

}

讀取步數

//查詢資料

- (void)readstepcount

];

}];

//執行查詢

[self.healthstore executequery:samplequery];

}

如何使Android應用程式獲取系統許可權

在 android 的api中有提供 systemclock.setcurrenttimemillis 函式來修改系統時間,可惜無論你怎麼呼叫這個函式都是沒用的,無論模擬器還是真機,在logcat中總會得到 unable to open alarm driver permission denied ...

C 獲取系統和程式的位數

如今 64 位系統越來越流行了 對於軟體開發人員來說 掌握 64 位開發技術將會有更好的發展空間 而且經過這幾年的發展 64 位開發工具也成熟了 例如 visual studio 2010 等後續版本 關於如何配置64位平台 msdn上有詳細的介紹 在很多時候 我們希望能相容老系統 於是配置了兩個編...

如何獲取iphone的硬體版本以及系統資訊

reference 獲取iphone的系統資訊使用 uidevice currentdevice 資訊如下 uidevice currentdevice systemname 系統名稱,如iphone os uidevice currentdevice systemversion 系統版本,如4.2...