7

I want to load an Image in the iOS simulator over a http uri as source. But nothing is shown on the screen expect the wireframe which can be made visible with the inspector. If you load the same code in Android it works fine and if you use a https uri instead of http it also works fine.

Example code:

render() { 
 return ( 
 <View> 
 <Image 
 source={{uri:https://facebook.github.io/react/img/logo_og.png'}} // works 
 // source={{uri: http://facebook.github.io/react/img/logo_og.png'}} // doesn't work
 style={{width: 400, height: 400}} 
 /> 
 </View> 
 ); 
}
asked Jul 1, 2016 at 20:17

2 Answers 2

6

The problem is that your are trying to load the image from a http connection and not from a https connection as it is demanded by apple. Try if your code works with another uri which uses https instead of http. In Android it should work fine with either http or https. Read more at https://github.com/facebook/react-native/issues/8520 and http://www.techrepublic.com/article/wwdc-2016-apple-to-require-https-encryption-on-all-ios-apps-by-2017/.

If you really want to load something over http you can edit the info.plist file and add your exception there. More detailed info here https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

answered Jul 1, 2016 at 20:17
6

add in info.plist

<key>NSAppTransportSecurity</key>
 <dict>
 <!--Include to allow all connections (DANGER)-->
 <key>NSAllowsArbitraryLoads</key>
 <true/>
 </dict>
answered Oct 25, 2017 at 10:30
1
  • Works for me in ios, but in android? Commented May 30, 2019 at 21:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.