Created
March 9, 2015 22:33
-
-
Save anonymous/aa3e6cc042b2b8486853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'firebase', 'ngCordova']) | |
.run(function($ionicPlatform, $ionicPopup) { | |
$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.Keyboard) { | |
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); | |
} | |
if(window.StatusBar) { | |
// org.apache.cordova.statusbar required | |
StatusBar.styleDefault(); | |
} | |
// Check for network connection | |
if(window.Connection) { | |
if(navigator.connection.type == Connection.NONE) { | |
$ionicPopup.confirm({ | |
title: 'No Internet Connection', | |
content: 'Sorry, no Internet connectivity detected. Please reconnect and try again.' | |
}) | |
.then(function(result) { | |
if(!result) { | |
ionic.Platform.exitApp(); | |
} | |
}); | |
} | |
} | |
// Get permissions on first launch for notifications | |
if(ionic.Platform.isIOS()) { | |
window.plugin.notification.local.promptForPermission(); | |
} | |
// Trigger alert when notification is fired but app is in foreground | |
window.plugin.notification.local.ontrigger = function (id, state, json) { | |
var notification = { | |
id: id, | |
state: state, | |
json: json | |
}; | |
$timeout(function() { | |
console.log("triggered from " + notification); | |
$rootScope.$broadcast("cordovaLocalNotification:triggered", notification); | |
}); | |
}; | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment