ionic app cannot connect cors enabled server with $http

cordova-plugin-whitelist seems to be “mandatory” at present. install it : cordova plugin add cordova-plugin-whitelist configure config.xml You can keep your current setup with * or change for more restrictive rules add a html policy on index.html, you shall add a Policy also. To authorise everything, here it is : <meta http-equiv=”Content-Security-Policy” content=”default-src *; style-src ‘self’ … Read more

Could not resolve all dependencies for configuration ‘:_armv7DebugCompile’

Please notice that section: Could not resolve all dependencies for configuration ‘:_armv7DebugCompile’. It can happen because building an android project with the crosswalk plugin try to build two apks : one for ARM, the other for x86. The solution is to install Android Support Repository : Open the SDK manager (from command line, type android). … Read more

Run a controller function whenever a view is opened/shown

By default, your controllers were cache and that is why your controller only fired once. To turn off caching for a certain controller you have to modify your .config(..).state and set the cache option to false. eg : .state(‘myApp’, { cache: false, url: “/form”, views: { ‘menuContent’: { templateUrl: “templates/form.html”, controller: ‘formCtrl’ } } }) … Read more

Http.get() working but not working in build(Release/Debug) in Ionic 4

I am Guessing that your are getting this because of android changes its http architecture. to make it working on Android go to your project root folder. yourAppFolder > resources > android > xml > network_security_config.xml Change your network security config to blow code. <?xml version=”1.0″ encoding=”utf-8″?> <network-security-config> <base-config cleartextTrafficPermitted=”true”> <trust-anchors> <certificates src=”https://stackoverflow.com/questions/59306640/system” /> </trust-anchors> … Read more

how to show pdf file in ionic app with out download

You will need to use ng-pdfviewer. AngularJS PDF viewer directive using pdf.js. <button ng-click=”prevPage()”>&lt;</button> <button ng-click=”nextPage()”>&gt;</button> <br> <span>{{currentPage}}/{{totalPages}}</span> <br> <pdfviewer src=”https://stackoverflow.com/questions/43496455/test.pdf” on-page-load=’pageLoaded(page,total)’ id=”viewer”></pdfviewer> and in your AngularJS code: var app = angular.module(‘testApp’, [ ‘ngPDFViewer’ ]); app.controller(‘TestCtrl’, [ ‘$scope’, ‘PDFViewerService’, function($scope, pdf) { $scope.viewer = pdf.Instance(“viewer”); $scope.nextPage = function() { $scope.viewer.nextPage(); }; $scope.prevPage = function() { … Read more

Adding google plus login to ionic app

Steps to Configure authentication in Device(android) ionic start newApp ionic platform add android cordova plugin add cordova-plugin-inappbrowser bower install ngCordova bower install ng-cordova-oauth -S include both script into index.html above cordova.js <script src=”https://stackoverflow.com/questions/37523038/lib/ngCordova/dist/ng-cordova.min.js”></script> <script src=”lib/ng-cordova-oauth/dist/ng-cordova-oauth.js”></script> <script src=”https://stackoverflow.com/questions/37523038/cordova.js”></script> Dependency injection include below code $scope.googleLogin = function() { console.log(‘In My Method’); $cordovaOauth.google(“Client ID”, [“https://www.googleapis.com/auth/urlshortener”, “https://www.googleapis.com/auth/userinfo.email”]).then(function(result) { console.log(JSON.stringify(result)); … Read more

Using environment variables / parameterizing config.xml

I’ve achieved that creating a template config.xml (the file is config.tpl.xml) and a before_prepare cordova hook to replace the variables in the template with the correct values and save the generated content in config.xml. The cordova hook uses the npm package es6-template-strings: npm install es6-template-strings –save-dev The hook is: #!/usr/bin/env node var fs = require(‘fs’); … Read more