I’m trying to use ionicPlatform.on() but I get undefined error.
in browser using serve and simulator using emulate
inspecting $ionicPlatform object gives me the below:
Object
$backButtonActions: Object
_hasBackButtonHandler: true
hardwareBackButtonClick: function (e) {
is: function (type) {
offHardwareBackButton: function (fn) {
onHardwareBackButton: function (cb) {
ready: function (cb) {
registerBackButtonAction: function (fn, priority, actionId) {
__proto__: Object
running ionic info provides this output
OS: Mac OS X Yosemite
Node Version: v0.12.0
Cordova CLI: 4.2.0
Ionic Version: 1.0.0-beta.14
Ionic CLI Version: 1.3.11
Xcode version: Xcode 6.1.1 Build version 6A2008a
ios-sim version: 3.1.1
Looking at the docs - .on() should be available…
I’m not sure what I’m missing…
Still getting an undefined for .on() (see error below)
[Error] TypeError: undefined is not a function (evaluating '$ionicPlatform.on')
(anonymous function) (app.js, line 39)
(anonymous function) (ionic.bundle.js, line 36892)
onPlatformReady (ionic.bundle.js, line 2329)
onWindowLoad (ionic.bundle.js, line 2317)
– Relevant code from app.js
.run(function($ionicPlatform, URLSchemeService)
{
$ionicPlatform.ready(function() {
if(window.StatusBar)
{
StatusBar.styleLightContent();
}
console.log("App Is Ready");
//Custom Event Handling for Custom URL Scheme
window.addEventListener('URL', function(event)
{
URLSchemeService.handleURL(event.detail.url);
});
$ionicPlatform.on('pause', function() {
console.log("App Is Paused");
});
$ionicPlatform.on('resume', function()
{
console.log("App Is Resumed");
});
});
})