jaget
jaget

Reputation: 2229

Ionic framework and angularjs imgcache not working on iOS device

I have built a hybrid app with ionic framework. I have used angular imgcache (https://github.com/jBenes/angular-imgcache.js/tree/master) to allow caching of images fetched from an external site.

I am using code such as:

<img img-cache ic-src="{{src}}"/>

It works a treat in browser (after using 'ionic serve') on command line. I have tested it in ionic view iOS app. I have now take the xcodeproj that it creates and distributed it for testing but the images do not load.

I have even added the cordova whitelist plugin and set metas to allow CORS requests.

Does anybody have any other ideas what the issue could be?

Upvotes: 6

Views: 1831

Answers (2)

RightHandedMonkey
RightHandedMonkey

Reputation: 1728

If you are not accessing an HTTPS endpoint, you might benefit from checking that your App Transport Security settings in the .plist file (found in platforms/ios/{app_name}/{app_name}-Info.plist)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
  <dict>
    ...
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
  </dict>
</plist>

From this resource: Publishing an Ionic Angular App for iOS - The Hidden Steps & Pitfalls .

Upvotes: 0

drys
drys

Reputation: 735

First, make sure you set the img cache to manual init ImgCacheProvider.manualInit = true;in your app.config function.

Second step - call ImgCache.$init() anytime after deviceready event (in your case, somewhere in the $ionicPlatform.ready function).

Upvotes: 3

Related Questions