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);
}
}];