@Hamza wrote:
I'm trying to use the new awesome ionic package service that we were looking for since ionic started
but seems the ionic package doesn't handle all plugins correctly, I keep getting an error when trying to use cordova.plugins.diagnostic which is properly installed within my projects
when I run "cordova plugin ls" I get below list:
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-device 1.0.1 "Device"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-statusbar 1.0.1 "StatusBar"
cordova-plugin-whitelist 1.0.0 "Whitelist"
cordova.plugins.diagnostic 2.2.3 "Diagnostic"
ionic-plugin-deploy 0.4.0 "IonicDeploy"
ionic-plugin-keyboard 1.0.7 "Keyboard"
phonegap-plugin-push 1.3.0 "PushPlugin"the code block that fails is:
$ionicPlatform.ready(function () { // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard // for form inputs) if (window.cordova && window.cordova.plugins) { if (window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.disableScroll(true); } $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { // do something try { cordova.plugins.diagnostic.isLocationEnabled(function (enabled) { if (enabled) { if (!$rootScope.watch) { $rootScope.watch = $cordovaGeolocation.watchPosition($rootScope.watchOptions); $rootScope.watch.then( null, function (err) { // error console.log(err); $rootScope.watch.clearWatch(); $rootScope.watch = null; loggedInAgent.setGPSEnabled(false); notifier({ title: "Your GPS is not Enabled", text: "error in watch.then", type: "warning" }); }, function (position) { notifier({ title: "Your GPS is Enabled", text: "For better experience, and best use for Buddy Agent, we recommend that you enable your GPS, then Close and Re-Open the app.", type: "success" }); var now = moment(); console.log(now); if (now.diff($rootScope.initTime, 'minutes') >= 5) { loggedInAgent.setGPSEnabled(true); loggedInAgent.setCurrentLocation(position); $rootScope.initTime = moment(); } notifier({ title: "Done", text: "all is fine.", type: "success" }); }); } } else { notifier({ title: "Your GPS is not Enabled", text: "not enabled.", type: "warning" }); } }, function (error) { notifier({ title: "Your GPS is not Enabled", text: "The following error occurred: " + error, type: "error" }); //console.error("The following error occurred: " + error); }); } catch (error) { notifier({ title: "islocation enabled failed", text: "The following error occurred: " + error, type: "error" }); } }); }
Posts: 1
Participants: 1