iOS错误:FBSOpenApplicationErrorDomain错误5.这是什么意思?

我已经看到错误4的报告,但不是5.我试图使用“openParentApplication:reply”请求时得到这个作为控制台消息。 日志中没有足够的信息来知道问题是在iOS代码,WK代码还是模拟器中。 我已经重新启动了SIM,并清理了项目。 有任何想法吗?

WK代码:

- (IBAction)sendRequest { NSDictionary *request = @{@"request":@"Request1"}; [InterfaceController openParentApplication:request reply:^(NSDictionary *replyInfo, NSError *error) { if (error) { NSLog(@"%@", error); } else { [self.label1 setText:[replyInfo objectForKey:@"response1"]]; [self.label2 setText:[replyInfo objectForKey:@"response2"]]; [self.label3 setText:[replyInfo objectForKey:@"response3"]]; } }]; } 

iOS代码:

 - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply{ NSLog(@"%s", __FUNCTION__); //([max intValue] - [min intValue]) + [min intValue] int randNum1 = arc4random_uniform(16); int randNum2 = arc4random_uniform(16); int randNum3 = arc4random_uniform(16); NSString *num1 = [NSString stringWithFormat:@"Test%d", randNum1]; NSString *num2 = [NSString stringWithFormat:@"Test%d", randNum2]; NSString *num3 = [NSString stringWithFormat:@"Test%d", randNum3]; if ([[userInfo objectForKey:@"request"] isEqualToString:@"Request1"]) { NSLog(@"containing app received message from watch: Request1"); NSDictionary *response = @{@"response1" : num1, @"response2" : num2, @"response3" : num3}; reply(response); } } 

唯一的控制台日志是:

 WatchKit Extension[48954:9523373] Error Domain=FBSOpenApplicationErrorDomain Code=5 "The operation couldn't be completed. (FBSOpenApplicationErrorDomain error 5.) 

我build议你尽量简化。 我在Swift中回答了一个非常类似的问题。 我会简化以下的逻辑:

WK代码

 - (IBAction)sendRequest { [InterfaceController openParentApplication:request reply:^(NSDictionary *replyInfo, NSError *error) { NSLog(@"Reply Info: %@", replyInfo); NSLog(@"Error: %@", error); }]; } 

iOS代码

 - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply { NSDictionary *response = @{@"replyKey" : @"replyValue"}; reply(response); } 

一旦你有这个工作,然后开始添加额外的parsing一步一次。 您也可以将debugging器附加到iOS应用程序,按照以下说明执行调用。 您可能不会在iOS应用程序上调用回复块,甚至不知道它。

我今天也面临同样的问题。

  • 从模拟器Dele删除应用程序
  • 重置模拟器😟
  • 重新启动XCode😦
  • info.plist更改

但是当我在Production运行应用程序,它工作😃。 应用程序在模拟器的生产模式下运行良好。

在这里输入图像说明

接下来,我删除了现有的dev模式scheme,并创build了另一个dev模式scheme,它工作😳。 然后它提醒了我,在应用程序中实现后台获取function时,我在该Devscheme中选中了Launch due to a background fetch event选项Launch due to a background fetch event选项。 后来我放弃了Background Fetch但忘了取消这个选项。 😠

在这里输入图像说明

在我的情况下,只有退出模拟器解决了这个问题。