2

I´m trying to open an URL with UIApplication, but when I run:

[[UIApplication sharedApplication] canOpenURL:urlToUpdate

The url is created with a String and

NSString *urlStringToOpenEscaped = [urlStringToOpen stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

NSURL *urlToUpdate = [NSURL URLWithString:urlStringToOpenEscaped];

Always returns FALSE.

I checked the URL is accessible from the iPad.

Any idea?

itsji10dra
  • 4,603
  • 3
  • 39
  • 59
xarly
  • 2,054
  • 4
  • 24
  • 40
  • Could you show the url string (urlStringToOpenEscaped ) for us? – BergP Nov 21 '12 at 18:54
  • sure: `itms-services://?action=download-manifest&url=http://address/App.plist` – xarly Nov 21 '12 at 19:01
  • Have a look at the comments in the first answer here. It might help. http://stackoverflow.com/questions/4695180/wireless-iphone-app-distribution-problem-with-itms-services-protocol – NikosM Nov 21 '12 at 19:06
  • Thankssss, I will try to review all cases. Additional information: I´ve checked that the URL: `http://address/App.plist` returns TRUE in the call, `canOpenURL`. – xarly Nov 21 '12 at 19:30

2 Answers2

1

The canOpenURL method is not meant to be used in order to test if a network url is reachable. According to the documentation:

This method guarantees that that if openURL: is called, another application will be launched to handle it. It does not guarantee that the full URL is valid.

So, it's a way of knowing if the resource specified by the url passed to the method, can be accessed/opened by an application on the system.

If you want to check whether a web address is reachable or not you'll have to execute the request and then handle the result in the response.

Kumar KL
  • 15,315
  • 9
  • 38
  • 60
NikosM
  • 1,131
  • 7
  • 9
  • I knew it, so previous to the call to UIApplication I checked with NSURLConnection that the resourse is avaliable, and I received a status 200. If I delete the `[[UIApplication sharedApplication] canOpenURL:urlToUpdate]` when I do the call to [[UIApplication sharedApplication] openURL:urlToUpdateWithHeaders]; doesn´t work, do nothing. – xarly Nov 21 '12 at 19:07
0

IOS 9 has some policy changes in using canopenURL to prevent ad services from misusing the API.

http://www.macrumors.com/2015/06/24/ios-9-policy-change-advertising-privacy/

Vivekanandan
  • 108
  • 1
  • 4
  • That's not it, it's not the info.plist for comgooglemaps. There's something else wrong. Probably a bug in GoogleMaps or iOS, or both – Radu Nov 12 '15 at 23:00