Hi,
I’m with a problem with $ionicPlatform.ready
When debugging the app on the google chrome, an alert is displayed.
But when I run the app on device, the alert isn’t displayed.
$ionicPlatform.ready(function () {
alert(‘ready’);
})
What I’m doing wrong ?
Thanks.
Can you please share your code sample ?
@devkiran
.run([
’$ionicPlatform’,
‘StartupService’,
function ($ionicPlatform,
StartupService) {
$ionicPlatform.ready(function () {
alert('ready');
})
})
})
How did you run the app on device ?
Just like this:
ionic build ios
and running from xcode
I had that problem also …
I saw this article http://stealthcode.co/multiple-calls-to-ionicplatform-ready/
However, during the app deployment testing, the ionic platform was not
yet ready. In that circumstance it turns out the first callback function
passed to $ionicPlatform.ready() wins and is called back when the
platform really is ready. Unfortunately, other callbacks passed to the
function are silently ignored.
So in order to make it work I use something like
var isWebView = ionic.Platform.isWebView();
if(isWebView === true) {
document.addEventListener('deviceready', function () {
initApp();
}, false);
} else {
$ionicPlatform.ready(function() {
initApp();
});
}
So now it works in browser AND device …