Hi guys.
I am developing an app with Ionic and was testing it in the browser. Everything was fine until I tried to deploy it in my iPhone 6 (iOS 10). On my iPhone, everything stopped working.
Investigating further, I've noticed that the $ionicPlatform.ready() function wasn't being called on my iPhone. To isolate the problem, I've created a totally new app with the Ionic blank template and one simple page that shows the result of every single call I make to my logger service.
Below, a code snippet from my app.js file:
.run(function($ionicPlatform, logger) {
logger.log('Angular run() called.'); // ## My code ##
$ionicPlatform.ready(function() {
logger.log('Ionic ready() called.'); // ## My code ##
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
When I run the debugging app in the browser, the page shows 2 lines:
[LOG] Angular run() called.
[LOG] Ionic ready() called.
But when I deploy the same app in my iPhone 6 (iOS 10), only the first line is shown:
[LOG] Angular run() called.
Why does the $ionicPlatform.ready() function is not being called on my iPhone? Am I missing something here?
The debugging app I've developed to isolate the problem can be found in my GitHub.
To reproduce the problem on iOS, follow these steps:
ionic build ios;ionic info from terminal/cmd prompt:Cordova CLI: 6.3.1
Ionic Framework Version: 1.3.1
Ionic CLI Version: 2.0.0
Ionic App Lib Version: 2.0.0
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 8.0 Build version 8A218a
Investigating further, I discovered that the $ionicPlatform.ready() is in fact being called. The problem was that my logController scope wasn't automatically refreshed when logger.log('Ionic ready() called.') was called. To remediate this, I just need to call $rootScope.apply() at the end of the $ionicPlatform.ready().
Adjusted code below:
.run(function($ionicPlatform, $rootScope, logger) {
logger.log('Angular run() called.');
$ionicPlatform.ready(function() {
logger.log('Ionic ready() called.');
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
$rootScope.$apply(); // This resolved!
});
});
Hi, i have a inexplicable problem on ios10 since i install Xcode8.0.
I'm using ionic 2.1.1.
The code is working good with a ionic serve and on android.
In ios, the problem is that the $ionicPlatform.ready event is not fired.
I tried a lot of time to reinstall plugin, to delete platform and rebuild application ... No issue, please help me, maybe 2 weeks that i have this problem.
Thanks by advance
PS : i tried the rootScope.$apply instruction but it didn't work.
Using this meta in index.html solved this problem for me:
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src * 'unsafe-inline' 'unsafe-eval'">
Having the same issue, anybody have a fix?
@davidsalib for me the suggestion by @corey-garvin solved the problem, my meta in index.html looks like this:
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
yes it has worked for me on ios...
but on android it's not, those meta are not recognized... Is it the same for you ?
@olivero86 I tried that and the app still infinitely loads on device. However it works on the simulator.
@olivero86 tested on ios 10.1.1 with ionic v1.3.2 (2016-10-24)
It still not working.
Hello!
I had that problem too (kind of) but I didnt know that was only happening in iOS10, in fact the app was working in iOS 9.2 and under (real device and simulator). I discover this issue submitting the app to AppStore (just the same as a week before, and this one was approved). They just rejected the app because of "The app is not supporting IPv6 connections"...it was great :____D , we changed all the server side, not literal IP use, at the end, we leave the server ready to support IPv6 and passing all the tests. We submitted again the app... and...they just rejected the app because of "The app is not supporting IPv6 connections". It was unbelievable...
Finally in an act of despair and after 100 absurd tests and even having read some similar cases of rejection I just did an update of my simulator version, in order to use the app under other version of iOS. I was realized that the problem was only for iOS 10+. And here is the problem: after June 16, Apple have changed their policies and they only support now IPv6 connections, despite that everybody says that you should update the meta tag "Content-Security-Policy" after that change, it's not true, at least in my case. Finally I only could compile normally without this meta tag.
greetings
@cotufaloschiflones I just run "ionic platform remove ios" and "ionic platform add ios", and the problem gone. I dont know why, but it solve the problem.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
@davidsalib for me the suggestion by @corey-garvin solved the problem, my meta in index.html looks like this:
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">