I am trying to check the internet connection on my app. When I launch the app on the iOS emulator, it doesn't work! I have use this code: https://gist.github.com/welcoMattic/c6415563d6607fbedf3e
I have 2 problems:
1) When I debug, I see that $ionicPlatform.ready (line 16 of the code on github) is never fired. I've tried everything I know to understand why but I didn't find a solution.
2) I have then tried to make the code work without the $ionicPlatform.ready. But then I always get connection.type= Unknown. I have changed the code several times, I always get 'unknown'.
So I wonder,
1) Is it the simulator that doesn't support the plugin?
2) Is there a problem with the code or am I missing something?
Thank you for your answers!
Well, I have found the solution (It is the small things that drives you crazy).
Here is the answer:
I was using the command: $cordova emulate ios To emulate an app using the ionic platform: "$ionic emulate ios"
What can bring confusion is that your app will launch with "$cordova" and it will work but some functionalities won't. That is what confuses me.
Anyway...
If you had the same issue, be sure to remove the already ios platform obtained using "$cordova platform add ios" and "$cordova emulate ios" before trying with "$ionic emulate ios".
So, to solve the problem, there is only two simple steps:
1) Remove the iOS cordova platform (in the console tap):
$cordova platform remove ios
2) Add the IOs ionic platform (in the console tap):
$ionic platform add ios
$ionic build ios
$ionic emulate ios
That's it!