Objective C-Is it possible to connect to BLE devices from iWatch?

旧城冷巷雨未停 提交于 2019-12-24 17:24:32

问题


Is it possible to get the BLE devices and connect to it using Watch Kit extension.In iPhone CoreBluetooth framework is used,what is the framework for iWatch

I am new to Watckit.Please help me with some solutions..


回答1:


Core Bluetooth is not currently available on watchOS 2.

I'm not sure if this would work for your application, but you could "daisy chain" your connection. You would use core bluetooth to connect your device to your iPhone, and then you could interact with your iPhone using WCSession from your apple watch.




回答2:


In iphone

if([WCSession isSuported])
{
WCSession *session=[WCSession defaultSession];
session.delegate=self;
[session activateSession];
}
NSError *error;
[session updateApplicationContext:@"DATA TO BE SEND" error:&error];

In iWatch repeat the session support check and add this code

-(void)session :(nonnull WCSession *)didRecieveApplicationContext:(nonull NSDictionary<NSString *,ud>*)applicationContext{

NSLog(@"recieved %@",applicationContext);
}


来源:https://stackoverflow.com/questions/35568770/objective-c-is-it-possible-to-connect-to-ble-devices-from-iwatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!