Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if URL can be opened from an iOS today widget

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

enter image description here

like image 225
andreacipriani Avatar asked Oct 08 '15 09:10

andreacipriani


1 Answers

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.

like image 54
Tom Harrington Avatar answered Sep 22 '22 16:09

Tom Harrington