I am working on sample watch kit app (Apple Watch + iPhone). Here my app is syncing fine. And also I worked on WCSession using data transferring (iPhone to apple watch). It is working fine when both are in active state. But I couldn't transfer data to Applewatch if it is inactive state (background state, sleep mode or foreground state). delegate method not calling.
- (void)applicationDidBecomeActive {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
if ([WCSession isSupported]) {
WCSession *session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
}
}
Here is my delegate method.
- (void)session:(nonnull WCSession *)session didReceiveMessage:(nonnull NSDictionary<NSString *,id> *)message replyHandler:(nonnull void (^)(NSDictionary<NSString *,id> * __nonnull))replyHandler {}
Please help me.
If iOS device and Apple watch are paired. Then when sending message through using WCSession, it will automatically wake the app.