I have an iOS app and I programmed a extension for it on appleWatch. I'm sending data (NSDictionary) to the appleWatch extension using transferUserInfo method. Everything works in the simulator but when I'm trying to run the application on real devices, it seems that the iWatch is not receiving anything though the iPhone is sending the data (I found this cause I debugged the sender side).
I have configured the WCSession on both sides. I have conformed the WCSessionDelegate in the class where I'm supposed to receive the data. I'm using session:didReceiveUserInfo: method to receive the data in ExtensionDelegate but still like I said everything works fine in the simulator but nothing is being transferred on real devices.
Does anyone has a clue to what the problem is?
here's 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 viewDidLoad method and it contains data.
on the receiver side (Watch Extension) I configure the WCSession and receive data in ExtensionDelegate.m like this:
- (void)applicationDidBecomeActive {
if ([WCSession isSupported]) {
session = [WCSession defaultSession];
session.delegate = self;
[session activateSession];
NSLog(@"Session activated in iWatch");
}
}
and I have this method to receive the 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];
}
}