iOS 9 - ATS in layman's terms

I use the code below to create a simple facebook like button. Obviously, its not working now in iOS 9. Is the problem using “socket” library to check for internet connectivity? Does socket use only “http” wich will fail ATS requirments? Or should I whitelist connections? Do I whitelist “google.com” & “facebook.com”?

 local test = socket.tcp()  test:settimeout(1000)                   -- Set timeout to 1 second  local testResult = test:connect("www.google.com", 80)        -- Note that the test does not work if we put http:// in front        if not(testResult == nil) then              local systemPlatformName = system.getInfo( "platformName" )              local URL              if( systemPlatformName == "iPhone OS" or systemPlatformName == "Mac OS X" ) then                   URL ="fb://profile/1573199902921487"               elseif( systemPlatformName == "Android" or systemPlatformName == "Win") then                    URL ="fb://page/1573199902921487"               else                    URL ="https://www.facebook.com/IckityGames/"              end               if(not system.openURL( URL )) then                  system.openURL("https://www.facebook.com/IckityGames/")               end  else

I did a few test,the internet connectivity works and I don’t have to whitelist “google.com

I then whitelise “facebook.com” and just call

system.openURL("https://www.facebook.com/IckityGames/")

still doesn’t work. It seems like system.openURL doesn’t work with iOS 9 using build 2015.2721. Anybody have the same issues?

The socket library does not use https, so it should be subject to the ATS rules.

system.openURL should work.

Rob

@Rob –  the socket library works – it does check if there is a connection.

If I take out the entire socket library code and just call system.openURL it returns nil

if I turn off ATS system.openURL still fails

  NSAppTransportSecurity =    {       NSAllowsArbitraryLoads = true     },

Anybody can confirm this? I’m using the current daily build 2015.2722

Does apple require a new permission to access the internet?​

Facebook and Google presumably have valid certificates and connect only through HTTPS, so ATS should not affect them.

Can you put together a simple sample project that demonstrates the issue and submit it as a bug report?

@Michael, sure but what’s the best way to make a sample project for iOS if I need certificates, do I need to generate a new ad hoc certificate?

Perhaps I am misunderstanding. The claim is that: [lua]system.openURL(“https://www.facebook.com/IckityGames/”)[/lua] does not work, correct?

I just tried that and it works just fine, building with Xcode 7 and running on iOS 9. Opening that URL should require no ATS configurations.

Yes, that’s the claim – at least for my project. Ugh, why doesn’t it work for me? This is what I hate about programming lol

The code above worked fine when I was running iOS 8 then when I upgraded to iOS 9 it doesn’t work. :frowning:

Are you sure that is the line that is failing for you? Make a simple project with only that one line of code in it. The app should start, then open the browser to the page you requested.

Yea, I made a simple app project with only this in the main. It doesn’t open the browser. I reset the network connections on my phone and it didn’t help.

system.openURL("https://www.facebook.com/IckityGames")

It works in the simulator.  What the heck is screwing this up for me? Ugh

What device are you using? What Xcode are you building with? What is the version number in the settings of the device? Still using 2722?

I tested on iPhone 5s and iPad mini . iOS 9.0.1

build 2722 and Xcode Version 7 (7A220)

How far can I go back on a the daily builds without needing to install Xcode 6?

I can’t use the public release because I have Xcode 7. I tested all the way back to build 2718 – still doesn’t work.  

I installed Xcode 6.4 and used build 2700 – build for iOS 8.4 and it worked :slight_smile:

Any clues as to what might be going on in my case?

@burnsj002 @Michael W

I’ve been tearing my hair out for hours over this - and much gnashing of teeth. I was just about to roll with burnsj002 suggestion and roll back.

No need! I have the solution. This:

https://coronalabs.com/blog/2015/09/17/about-app-transport-security-ats/

did nothing for me. Whitelisting or ATS disabling did not work. This does:

https://docs.coronalabs.com/daily/plugin/facebook-v4/index.html

Those build settings are needed for iOS9.

I can now do: system.openURL("https://www.facebook.com/etc") for a FB like button!

:slight_smile:

@burnsj002, iOS 9 requires you to use a different Facebook plugin (v4) and you have to include additional things in your build settings for it to work. This is why iOS 8.4 isn’t giving you issues. The ATS issue is an iOS 9 issue only.

Rob

I did a few test,the internet connectivity works and I don’t have to whitelist “google.com

I then whitelise “facebook.com” and just call

system.openURL("https://www.facebook.com/IckityGames/")

still doesn’t work. It seems like system.openURL doesn’t work with iOS 9 using build 2015.2721. Anybody have the same issues?

The socket library does not use https, so it should be subject to the ATS rules.

system.openURL should work.

Rob

@Rob –  the socket library works – it does check if there is a connection.

If I take out the entire socket library code and just call system.openURL it returns nil

if I turn off ATS system.openURL still fails

  NSAppTransportSecurity =    {       NSAllowsArbitraryLoads = true     },

Anybody can confirm this? I’m using the current daily build 2015.2722

Does apple require a new permission to access the internet?​

Facebook and Google presumably have valid certificates and connect only through HTTPS, so ATS should not affect them.

Can you put together a simple sample project that demonstrates the issue and submit it as a bug report?