My watch needs to request an image from the containing app. In the watch's controller, I have:
- (void)getOrgLogo {
NSString *host = mfaInfo[@"host"];
NSDictionary *getOrgLogoRequest = @{@"request":@"getOrgLogo", @"host":host};
[MyInterfaceController openParentApplication:getOrgLogoRequest reply:^(NSDictionary *replyInfo, NSError *error) {
if (error) {
...
} else if (replyInfo == nil) {
// I am always getting into this block!!!
} else {
UIImage *orgLogo = replyInfo[@"orgLogo"];
if (orgLogo != nil) {
[self.orgLogoImageView setImage:orgLogo];
}
}
}];
}
In my main app, I send a request to the server to get the image, then pass the image back to watch:
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
...
if ([[userInfo objectForKey:@"request"] isEqualToString:@"getOrgLogo"]) {
NSString *host = userInfo[@"host"];
[self handleWatchKitGetOrgLogoRequest:reply withHost:host];
}
...
}
- (void)handleWatchKitGetOrgLogoRequest:(void (^)(NSDictionary *))reply withHost:(NSString *)host{
NSMutableDictionary *response = [[NSMutableDictionary alloc] init];
// A server request to get the image
[OktaAPIClient getLogoUrlFromHost:host withSuccess:^(UIImage *image) {
// I'm getting in here - indicating I successfully got the image
response[@"orgLogo"] = image;
// I double checked the value of response here - it's not nil!
reply(response);
} withFailure:^(UIImage *image) {
...
reply(response);
}];
}
As commented in the code above, I checked the value of response right before I pass it back to watch and confirmed that it contain a value (a UIImage), however in the callback of the watch code, this reply becomes nil. I do not know what happens in the process. Any thoughts?