从iOS扩展开放URL方案 [英] Open URL scheme from iOS extension

查看:211
本文介绍了从iOS扩展开放URL方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码返回 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:

我已经测试了打开 URLApp:// <来自safari的/ code>它适用于我。

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

我还使用了一些例子 ,了解如何使用url方案打开包含应用程序。

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

推荐答案

我找到了这个答案这里由Julio Bailon提供:

I found this answer here by 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];

这篇关于从iOS扩展开放URL方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆