iOS 8.3共享扩展 – 启动URLscheme

因为iOS 8.3更新我的共享扩展(使用URL Schemes调用我的主应用)停止工作。 所以我发现UIWebView的方法,我不得不启动我的应用程序了。 我也尝试了苹果推荐的方法,使用NSExtensionContext,但仍然没有结果。 对此有何想法? 我的代码如下:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; [self.view addSubview: webView]; NSString *urlString = "com.myappscheme://shareextension"; NSString * content = [NSString stringWithFormat : @"<head><meta http-equiv='refresh' content='0; URL=%@'></head>", urlString]; [webView loadHTMLString:content baseURL:nil]; 

 [self.extensionContext openURL:[NSURL URLWithString:urlString] completionHandler:^(BOOL success) { NSLog(@"fun=%s after completion. success=%d", __func__, success); }]; 

我尝试从我的SLComposeServiceViewController控制器的didSelectPost方法执行这两个代码块,这是以前工作正常,在更新我的设备到iOS 8.3之前

extensionContext.openURL仅用于“今日”扩展。 苹果公司并没有提供公开的API来实现这一点,而在iOS 8.3中,苹果已经阻止了一些解决方法。 这似乎是devise。 如果您认为需要此function,请打开增强请求/错误报告。

你可以试试这个代码,这个工作,但我不知道是否会被苹果接受。

 UIResponder* responder = self; while ((responder = [responder nextResponder]) != nil) { NSLog(@"responder = %@", responder); if ([responder respondsToSelector:@selector(openURL:)] == YES) { [responder performSelector:@selector(openURL:) withObject:[NSURL URLWithString:@""]]; } }