小编Hes*_*ter的帖子

iOS蓝牙peripheralManagerDidUpdateState从未被调用

我正在尝试将 iPhone 设置为心率监视器并使用标准心率服务发送信息,以便我在 PC 上运行的应用程序可以检索数据。我是 iOS 新手,但之前我已经在 Android 和 Windows 上运行过蓝牙功能。我正在关注这里的信息,但我在第一个障碍处就跌倒了......

根据文档中的指定,我首先调用

CBPeripheralManager *myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:(id<CBPeripheralManagerDelegate>)self queue:nil options:nil];
Run Code Online (Sandbox Code Playgroud)

我还实现了 PeripheralManagerDidUpdateState 回调,但问题就在这里。这个回调永远不会运行!我等了几分钟,什么也没发生。我怀疑我错过了一个非常简单的步骤,因为我搜索了一整天,但在网上什么也没找到!谁能解释一下在代码中和用我的 iPhone 进行实际操作时要采取的明确步骤吗?在这个回调运行之前它必须有连接吗?它必须与任何东西配对吗?

这是完整的代码。一切运行良好,我没有收到任何错误。

#import "ViewController.h"
@import CoreBluetooth;

@interface ViewController()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"App running...");

    //Create the peripheral manager
    CBPeripheralManager *myPeripheralManager = [[CBPeripheralManager alloc] initWithDelegate:(id<CBPeripheralManagerDelegate>)self queue:nil options:nil];
}

- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral{
    int state = peripheral.state;
    NSLog(@"Peripheral manager state …
Run Code Online (Sandbox Code Playgroud)

bluetooth objective-c ios core-bluetooth cbperipheralmanager

2
推荐指数
1
解决办法
2368
查看次数

Apple HealthKit - 锻炼是否与心率数据相关?

我正在编写自己的健身应用程序,希望能够弥合Fitbit应用程序和Apple Health之间的空白(我最终放弃了我的Blaze用于Apple Watch).到目前为止,我能够检索过去7天的锻炼,但是当我点击查看锻炼时,我想显示锻炼的心率图(如Fitbit).锻炼是否包含锻炼期间记录的心率样本,或者我是否需要分别查询与锻炼匹配的开始和结束时间的心率?我玩了一下,试图在文档中找到答案,但我发现它有点难以理解,如果我错过了一些明显的东西,那就很抱歉!

ios healthkit

2
推荐指数
1
解决办法
495
查看次数