Reputation: 10063
Primarily I was trying to get connection through Socket.io but soon figured out that nothing from "outside" can be loaded into my Cordova/iOS app. I checked the whitelist settings in config.xml. They seemed to be fine but just in case I added
Unfortunately that didn't help. I tried to remove the whitelist plugin
cordova plugin add org.apache.cordova.whitelist
Plugin "cordova-plugin-whitelis" is not present in the project. See
cordova plugin list
.
So I checked cordova plugin list and that returned
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-dialogs 1.1.1 "Notification"
cordova-plugin-vibration 1.2.0 "Vibration"
cordova-plugin-whitelist 1.1.0 "Whitelist"
I guess the one above may be some sort of default one?
My next try was removing the following meta tag from index.html
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
But that didn't help either...
Upvotes: 4
Views: 1219
Reputation: 21
iOS 9 has a new security feature called App Transport Security (ATS), which forces the use of https in your AJAX calls from within HTML5 apps, in frameworks like Cordova or Ionic. There's a new plugin that overrides this behavior, by adding the NSAppTransportSecurity tag that Adam mentioned above. It's called "cordova-plugin-disable-nsapptransportsecurity". To fix yourself up, just run this:
cordova plugin add cordova-plugin-disable-nsapptransportsecurity
For more about this issue, see here: iOS9 ATS: what about HTML5 based apps?
Plugin information is here: https://www.npmjs.com/package/cordova-plugin-disable-nsapptransportsecurity
This solution is independent of the whitelist plugin, which appears to have no effect in iOS. You may as well just not install it for iOS.
Upvotes: 2
Reputation: 10063
After many hours of struggling with the Cordova settings I'm still unsure what Whitelist I have installed and what is the best way of setting it up
but one thing that certainly helped me was inserting into Info.plist
(may be something like HelloWorld-Info.plist
)
the following tags
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
After that I can connect through web-socket or load external images!
I hope this will help some time the others.
Upvotes: 5
Reputation: 31
I wasn't sure if the sources of images are from "http" protocol or "https". My images were all from "http", which didn't display correctly. After having changed the source to https, it started to display images.
Upvotes: 1