使用iOS SDK从microsoft-band访问心率数据

时间:2015-09-08 21:17:08

标签: ios objective-c microsoft-band

我无法从微软带获取心率数据。我的iOS应用程序上显示心率文本标签不会更改。 (CoreBluetooth框架已添加)。

if (self.client && self.client.isDeviceConnected){
   [self output:@"Starting Heart Rate updates..."];
   [self.client.sensorManager startHeartRateUpdatesToQueue:nil errorRef:nil withHandler:^(MSBSensorHeartRateData *heartRateData, NSError *error) {
        self.heartRateLabel.text = [NSString stringWithFormat:@"Heart Rate: %d bpm", heartRateData.heartRate];
    }];

}

1 个答案:

答案 0 :(得分:2)

从Band访问心率数据需要一次性用户同意。以下API可用于请求和检查用户同意:

/**
 * Check user consent for heart rate.
 * @return MSBSensorUserConsent Returns a MSBSensorUserConsent value based on user consent.
 */
 - (MSBUserConsent)heartRateUserConsent;

/**
 * Request user consent for heart rate.
 * @param completion Completion block to invoke with the user response.
 */
 - (void)requestHRUserConsentWithCompletion:(void (^)(BOOL userConsent, NSError *error))completion;

上述API的示例代码可在Band SDK documentation(第2.4.1.2节)中找到。