addo.lou addo.lou - 3 years ago 190
Android Question

Calling API from Apache Cordova app not working (Android)

I am working on an Apache Cordova app that gets stuck trying to load a map. It works in android 4.2.2 but not working on more recent versions 7.0.0/7.1.1.

I try to call it from my index.html file with the next line:

<script type="text/javascript" src="http://api.cercalia.com/api/cercalia.js?key=[key]&theme=red"></script>


Also I created a test file within my JS folder with the code from the API online and it works perfectly.

I suspect that the
whitelist
plugin might not be working properly.

Any ideas on how to tackle this?

Answer Source

Apparently I just had to add the next meta tag on the index.html head:

<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src  'self' 'unsafe-inline' *">

This will load the map correctly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download