iOS 8.3共享扩展 - 启动URL方案 [英] iOS 8.3 Share Extension - Launching URL Schemes

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

问题描述

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

since iOS 8.3 update my share extension (which calls my main app using URL Schemes) stopped working. So I found out that the UIWebView approach I had to launch my app is not working anymore. I also tried the approach Apple recommends, using NSExtensionContext, and still no results. Any thoughts about this? My code follows:

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之前

I try executing both blocks of code on the didSelectPost method from my SLComposeServiceViewController controller, which was where it worked fine previously, before updating my device to iOS 8.3

推荐答案

extensionContext.openURL 仅适用于今日延期。 Apple没有提供公共API来实现这一点,而且在iOS 8.3中,Apple已经阻止了一些变通方法。这似乎是设计的。如果您认为需要此功能,请打开增强请求/错误报告。

extensionContext.openURL is meant only for Today extensions. Apple does not provide a public API to achieve this, and it seems in iOS 8.3, Apple has blocked some of the workarounds. This seems by design. If you believe this functionality is needed, please open an enhancement request / bug report.

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

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