My problem is that I can't find out if a certain URL can be opened from an iOS widget. The method canOpenURL: is not available on today's widget because there is no UIApplication class.
Moreover the method openURL: of NSExtensionContext returns YES for the boolean "success", even with an invalid URL.
The code below enters the else condition (success BOOL is always YES) but in the same time the simulator shows a popup error, as you can seen in the attached image.
NSURL* invalidURL = [NSURL URLWithString:@"fake://blablabla"];
[self.extensionContext openURL:invalidURL completionHandler:^(BOOL success) {
if (success == NO) {
DDLogWarn(@"Can't open URL: %@", invalidURL);
}
else{
DDLogInfo(@"Successfully opened URL: %@",invalidURL);
}
}];
It's a known bug. I filed this issue with Apple last year (rdar://18107612) when iOS 8.0b5 was current, and it's still an open issue.
File your own bug with Apple at http://bugreport.apple.com and hope for the best.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With