App works in browser, DevApp and Ionic View, but not when using Deploy


#1

I am struggling with a very odd issue. I have a v1 app with a new page/controller that uses Google Maps API (no native plug-in used - just Javascript Google Maps API). The app works perfectly via Browser, DevApp and Ionic View. I am on Ionic Pro. The app builds fine locally and via Ionic Pro Dashboard. However, when I Deploy the app via the dashboard, it doesn’t work on iOS or Android. I have tried all sorts of variations on using (and not using) $ionicPlatform.ready(function(){initialize();}); or ionic.Platform.ready(initialize()); or google.maps.event.addDomListener(window, 'load', initialize); or just plain initialize();. I have also used ionic.Platform.isWebView(); to do document.addEventListener('deviceready', function () { initialize(); }, false); for browser. Any ideas why it is not working (not loading Google Maps) once deployed?


#2

For those interested, updating my Content-Security-Policy to <meta http-equiv="Content-Security-Policy" content="default-src 'self' gap://ready *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *;"> resolved it. Many posts out there mention adding file://* to default-src but I do not recommend that, because on iOS, you will be prompted to allow index.html to utilize your location. :wink: