1

Really a bizzare issue, it was all working till now, but when we tried to build the cross platform app into the iphone 5s having ios 9, the images won't just appear, neither do the image load from the api to the img src work, specially whenever I try to call the following code.

<img ng-if="eachItem.Image.length > 0" 
src="https://<name hidden>.s3.amazonaws.com/images/{{eachItem.Image}}"
fallback-src="images/no_foto.jpg" alt="" class="spac-bdr">

But the interesting part is everything works fine in ios 8. Alos the apis all working fine. Just the images won't load.

But there is no such issue for the android app built using the same code. It seems to affect the apps running only on devices having ios 9 OS.

Any Idea how to overcome the issue?

Kailas
  • 7,350
  • 3
  • 47
  • 63
  • What does Inspect Element say? Any console errors? – Huey Oct 05 '15 at 11:29
  • Can we inspect element it? It's an app right? For the web version we could carry out that. Adding to this, it works smoothly on web version. – Kailas Oct 05 '15 at 11:44
  • 1
    In Chrome at least, you can use [remote debugging](https://developers.google.com/web/tools/setup/remote-debugging/remote-debugging) for both Android and iOS. – Huey Oct 05 '15 at 11:44

4 Answers4

2

Think there was some issue trying to access images from a different server. While the apis are pointed to a different one though. The following addition to the plist helped me resolve the issue.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>
Kailas
  • 7,350
  • 3
  • 47
  • 63
  • As i already told very detailed over here -> http://stackoverflow.com/a/32710127/3671726 the way you describe is **not** the way someone should use. I don't know why everybody thinks "oh hey, i just allow every network request" - where is your idea of security? – Sithys Oct 05 '15 at 12:43
2

As i commented already under the answer from @Kailas, the way he posted is not the recommended way. Please, to everybody who read this: Think about the security of your application!

Although i already told and linked my detailed answer to the iOS 9 Ajax / ATS Problem, i'm going to do a fullquote here because of completeness.

So fullquote following - Original post over here

As far as i understood the whole ATS (App Transport Security - iOS 9) thing, the recommended method from area28 should not be the one you're using inside an application.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>

This will allow all external requests to every domain what is definitively not the way you should use it. In my opinion you should define a new <dict> inside your info.plist and add this code to it (to edit the info.plist you can just use a normal text editor like sublime text etc.):

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>domain.tld</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
        </dict>
    </dict>

This will only allow requests to the domain you specified. The described way is the one which apple introduced on the WWDC 2015. As you can see on the screenshot, it's the way apple want the users to use it.

If you haven't specified anything, you'll get

Failed to load webpage with error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

So, change it like i said and the error is gone away. enter image description here

Community
  • 1
  • 1
Sithys
  • 3,655
  • 8
  • 32
  • 67
  • 1
    Thank you buddy for your good guidance. I will look into this in detail. We require to use the right way and not just a fix. Thanks – Kailas Oct 06 '15 at 04:49
  • This solution didn't worked for me on iOS 9.3. So I ended up with this solution to load local files : [MySolution](http://stackoverflow.com/questions/33773877/not-allowed-to-load-local-resource-ios9-cordova-app/38024669#38024669) – sumitb.mdi Jun 25 '16 at 03:33
1

Make sure the path origin in the config.xml file has the domains required to pull the images (for example, my images are served from AWS S3 so I needed this line below)

<access origin="*s3.amazonaws.com*" subdomains="true" />

I solved my issue by adding this to the .plist file just before building from xCode.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key><true/>
</dict>
0

If you are working cordova cli then you will have to manually make the changes to config.xml, plugin.xml and info.plist files. remove the configs from the platforms/ios/ios.json file. That will rebuild all the previous files on every cordova build. I was having issues loading images from the graph api so i removed this from the ios.json file.

{
   "xml": "<access origin=\"https://graph.facebook.com\" />",
   "count": 1
}
Ridan
  • 319
  • 2
  • 14