error catching

This commit is contained in:
arzynik 2014-10-29 15:51:35 -07:00
parent e900fdc196
commit 2c900f6416
3 changed files with 9 additions and 9 deletions

View File

@ -516,8 +516,8 @@ NGApp.run( function ( $rootScope, $location, MainNavigationService ) {
App.alert = function(txt, title, useNativeAlert, fn) {
setTimeout(function() {
if (useNativeAlert && App.isPhoneGap) {
parent.navigator.notification.alert(txt, null, title || 'Crunchbutton');
if (useNativeAlert && App.isPhoneGap && parent.window.navigator && parent.window.navigator.notification) {
parent.window.navigator.notification.alert(txt, null, title || 'Crunchbutton');
} else if ( useNativeAlert ) {
alert( txt );
} else {
@ -527,8 +527,8 @@ App.alert = function(txt, title, useNativeAlert, fn) {
};
App.confirm = function(txt, title, fn, buttons) {
if (App.useNativeConfirm && App.isPhoneGap) {
return navigator.notification.confirm(txt, fn, title || 'Crunchbutton', buttons || 'Ok,Cancel' );
if (App.useNativeConfirm && App.isPhoneGap && parent.window.navigator && parent.window.navigator.notification) {
return parent.window.navigator.notification.confirm(txt, fn, title || 'Crunchbutton', buttons || 'Ok,Cancel' );
} else {
return confirm(txt);
}

View File

@ -34,7 +34,7 @@ NGApp.factory('HeartbeatService', function($rootScope, $resource, $interval, Loc
service.load(function(data) {
service.date = new Date;
if (App.isPhoneGap) {
if (App.isPhoneGap && parent.plugins && parent.plugins.pushNotification) {
var complete = function(){};
PushService.badges = parseInt(data.tickets) + parseInt(data.orders['new']);
parent.plugins.pushNotification.setApplicationIconBadgeNumber(complete, complete, PushService.badges);
@ -56,7 +56,7 @@ NGApp.factory('HeartbeatService', function($rootScope, $resource, $interval, Loc
$rootScope.$on('appResume', service.check);
$rootScope.$on('appPause', function() {
if (App.isPhoneGap) {
if (App.isPhoneGap && parent.plugins && parent.plugins.pushNotification) {
var complete = function(){};
parent.plugins.pushNotification.setApplicationIconBadgeNumber(complete, complete, PushService.badges);
}

View File

@ -4,7 +4,7 @@
NGApp.factory('LocationService', function($http, $resource, $rootScope) {
if (App.isPhoneGap) {
if (App.isPhoneGap && parent.window.plugins && parent.window.plugins.backgroundGeoLocation) {
var bgGeo = parent.window.plugins.backgroundGeoLocation;
@ -101,7 +101,7 @@ NGApp.factory('LocationService', function($http, $resource, $rootScope) {
//alert('Your location services are off, or you declined location permissions. Please enable this.');
}, { enableHighAccuracy: true });
}
if (App.isPhoneGap) {
if (App.isPhoneGap && bgGeo) {
bgGeo.start();
}
};
@ -123,7 +123,7 @@ NGApp.factory('LocationService', function($http, $resource, $rootScope) {
parent.window.navigator.geolocation.clearWatch(watcher);
watcher = null;
if (App.isPhoneGap) {
if (App.isPhoneGap && bgGeo) {
bgGeo.stop();
}
}