1 Reply
      Latest reply on Dec 3, 2016 5:39 AM by eskimo
      avro Level 1 Level 1 (0 points)

        I am having a problem with and app on my iPhone 6S running iOS 10.2 beta which is not replicated on the iOS 10.2 beta simulator for iPhone 6S in the latest XCode beta or on my iPad Pro with 10.2 beta or on my iPhone 5SE running 10.1.


        There are two links set up in the App which go to URLs on my company's website.  As these links are user-specific they are made up of a concatenated string which is used as the argument in the openURL call.  When the link is clicked on the iPhone 6S it does nothing - on all other devices and the simulator it opens the correct page in Safari.


        Elsewhere in the App are fixed links to information pages on the company's website.  These also use the openURL command but when they are tapped on the iPhone 6S they open up Safari perfectly and go to the correct page.


        The code for the links that works is:


        - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
          NSString* url=@"";
          if([indexPath row] == 0){
          url = @"http:/www.adv.co.uk/ipad.php";
          else if([indexPath row] == 1){
          url = @"http://www.adv.co.uk";
          [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];


        The code which has the problem is:


           NSString* url = [NSString stringWithFormat:@"http://online.adv.co.uk/ipad/progress.php?activationname=%@",[Utils setting:kActivationName]];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];


        If I comment out the declaration of url and replace it with a hard-coded declaration, as shown below, then Safari opens properly:


        //    NSString* url = [NSString stringWithFormat:@"http://online.adv.co.uk/ipad/
            //progress.php?activationname=%@",[Utils setting:kActivationName]];
            NSString* url = @"http://online.adv.co.uk/ipad/progress.php?activationname=davidanson1";
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];


        I have tested the value of setting to make sure it is correctly set.  It is. 


        Does anyone have any idea what could be causing the problem or could they suggest an alternative way of coding which uses different commands to see if that solves the problem?





        • Re: openURL not working on iPhone 6S with iOS 10.2 beta
          eskimo Apple Staff Apple Staff (13,925 points)

          If you split line 5 of your last listing to:

          1. create the URL

          2. log the URL

          3. call -openURL:

          what do you see logged?

          Just by way of general advice, when you construct URLs from component parts, it’s a good idea to not use string manipulation routines but instead use NSURLComponents.  It will do the right thing with regards text encodings, percent escaping, and so on.  I don’t see any evidence that this is a factor in this issue, but it’s a good thing to keep in mind for the future.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"