I have an iOS app and I programmed the extension for it on appleWatch. I am sending data (NSDictionary) to the appleWatch extension using the transferUserInfo method. Everything works in the simulator, but when I try to run the application on real devices, it seems that iWatch does not receive anything, although the iPhone sends data (I found this reason, I debugged the sender side).
I configured WCSession on both sides. I combined WCSessionDelegate in a class where I should receive data. I use session: didReceiveUserInfo: a method for receiving data in ExtensionDelegate, but still, as I said, everything works fine in the simulator, but nothing is transmitted on real devices.
Does anyone know what the problem is?
here is the code: in the sender side:
inside my class MensaViewController.m
- (void)viewDidLoad
if ([WCSession isSupported]) {
session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
}
NSLog(@"A dish is being sent");
[session transferUserInfo:dishDictionary];
}
dishDictionary is declared inside the viewDidLoad method and contains data.
on the receiver side (Watch Extension) I configure WCSession and get the data in ExtensionDelegate.m as follows:
- (void)applicationDidBecomeActive {
if ([WCSession isSupported]) {
session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
NSLog(@"Session activated in iWatch");
}
}
and I have this method for getting data:
- (void)session:session didReceiveUserInfo:(NSDictionary<NSString *,id> *)userInfo{
NSLog(@"Received data from the iPhone");
NSArray<NSString*> *dictionaryKeys = userInfo.allKeys;
for(int i = 0; i < dictionaryKeys.count; i++){
Boolean equalsMensaString = [dictionaryKeys[i] isEqualToString:@"beilagen"];
if(equalsMensaString)
[self handleTransferredDish:userInfo];
Boolean equalsNewsString = [dictionaryKeys[i] isEqualToString:@"article"];
if(equalsNewsString)
[self handleTransferredNews:userInfo];
Boolean equalsEventString = [dictionaryKeys[i] isEqualToString:@"description"];
if(equalsEventString)
[self handleTransferredEvents:userInfo];
}
}