Reputation: 513
I'm trying to launch the container app from the extension. (An Action extension) The container app has a working URL scheme (example://) and I can validate this by navigating to that URL in Safari.
When I try to use the -[NSExtensionContext openURL:completionHandler:] to launch the container app, I get an unsuccessful callback and nothing happens.
The iOS 8 Beta 2 changes say that the openURL method should work now, but is this still a bug or am I doing something wrong?
Upvotes: 7
Views: 7117
Reputation: 1900
IMPORTANT Apple allows any Today widget to use the openURL:completionHandler: method to open the widget’s own containing app.
If you employ this method to open other apps from your Today widget, your App Store submission might entail additional review to ensure compliance with the intent of Today widgets.
To learn more, read App Store Review Guidelines and iOS Human Interface Guidelines, linked to from Apple’s App Review Support page
Upvotes: 0
Reputation: 744
If you use unicode character you must convert to utf8 string.
NSString* toUtf8= [yourString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *urlString = [NSString stringWithFormat:@"openMap://?lat=%f&lon=%f&%@",[self.koordX floatValue],[self.koordY floatValue],toUtf8];
[self.extensionContext openURL:[NSURL URLWithString:urlString] completionHandler:nil];
Upvotes: 0
Reputation: 141
It worked for me in a Today Extension using this code:
NSExtensionContext *myExtension=[self extensionContext];
[myExtension openURL:[NSURL URLWithString:@"http://google.com"] completionHandler:nil];
However, it might not work in Action Extensions. From the documentation:
Each extension point determines whether to support this method, or under which conditions to support this method. In iOS 8.0, only the Today extension point supports this method.
Upvotes: 11
Reputation: 4565
My solution is creating a UIWebView
and loading a request with the url in it
Upvotes: 4