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];
and
[self.extensionContext openURL:[NSURL URLWithString:urlString] completionHandler:^(BOOL success)
{
NSLog(@"fun=%s after completion. success=%d", __func__, success);
}];
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
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.
You can make a try with this code, this works but I don't know if would be accepted by Apple.
UIResponder* responder = self;
while ((responder = [responder nextResponder]) != nil) {
NSLog(@"responder = %@", responder);
if ([responder respondsToSelector:@selector(openURL:)] == YES) {
[responder performSelector:@selector(openURL:) withObject:[NSURL URLWithString:@""]];
}
}
来源:https://stackoverflow.com/questions/29657857/ios-8-3-share-extension-launching-url-schemes