【发布时间】:2017-12-01 13:01:05
【问题描述】:
尝试使用 updateApplicationContext 将数据从 iPhone 共享到 Apple Watch,Watch 连接 (WCSession) 的传输用户信息在模拟器中工作,但在设备上尝试相同但无法正常工作。
设备:iPhone 6 plus(OS 11.1)、apple watch-Series 2(Watch OS 4.1)。
处理 defaultSession 并为 watchConnectivity 实现必要的委托方法。
iPhone 端:
步骤:1
if ([WCSession isSupported])
{
[[WCSession defaultSession] setDelegate:self];
[[WCSession defaultSession] activateSession];
}
步骤:2
[[WCSession defaultSession] transferUserInfo:dataDict];
Apple Watch 方面:处理 defaultSession 步骤:1
if ([WCSession isSupported])
{
[[WCSession defaultSession] setDelegate:self];
[[WCSession defaultSession] activateSession];
}
步骤:2
-(void)session:(WCSession *)session didReceiveUserInfo:(NSDictionary<NSString *,id> *)userInfo
{
// code for data parsing which get from userInfo dictionary.
}
【问题讨论】:
标签: objective-c watchos