1

I have this code that return success = NO

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

     [self.extensionContext completeRequestReturningItems:nil completionHandler:nil];

 }];

So and I can't open containing app from my share extension when I debug it.

I've configured main target of contained app like this:

enter image description here

I've tested open URLApp:// from safari and it works for me.

I also used some examples provided here to understand how to open containing app using url scheme.

4

2 回答 2

0

编辑:好的,这里只是稍微更正一下。我让它在标签上放置一个按钮,就像上面建议的那样,下面的代码:

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

我将它与“Touch Up Inside”活动联系起来。但是,这也会导致应用在用户滚动 Today 视图时启动。

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

我遇到了同样的问题。但是,由于iOS 8 的第一个 beta版本的发行说明中提到,现在似乎没有解决方案:

已知问题:openURL 不适用于扩展。

所以我想我们至少要等到 beta 2。

于 2015-04-15T18:12:24.693 回答
0

我在这里找到了 Julio Bailon 的答案:

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];
于 2015-04-15T18:18:26.273 回答