从iOS扩展中打开URLscheme

我有这个代码,返回success = NO

 [self.extensionContext openURL:[NSURL URLWithString:@"URLApp://"] completionHandler:^(BOOL success) { [self.extensionContext completeRequestReturningItems:nil completionHandler:nil]; }]; 

所以,当我debugging时,我无法从共享扩展中打开包含应用程序。

我已经configuration包含应用程序的主要目标是这样的:

在这里输入图像说明

我已经从safaritesting了开放的URLApp://它适用于我。

我也用这里提供的一些例子来了解如何使用urlscheme打开包含应用程序。

编辑:好的,只是在这里稍微纠正一下。 我把它放在标签上,就像上面build议的和下面的代码一样:

  NSURL *url = [NSURL URLWithString:@"floblog://"]; [self.extensionContext openURL:url completionHandler:nil]; 

我将它链接到“Touch Up Inside”事件。 但是,这也会导致应用程序在用户滚动“今日”视图时启动。

=======================================

我遇到了同样的问题。 然而,从iOS 8的第一个testing版发布笔记来看,目前看来目前还没有解决scheme:

已知问题:openURL不能从扩展中使用。

所以我想我们至less要等到beta2。

Julio Bailon 在这里find了这个答案:

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