I deviceready doesn't fire or fires very late in my ionic app when I run it on my iOS device with
ionic run ios --device -lcs
I removed all the plugins with ionic plugin rm ...
, deleted the content of the plugins/
directory and reinstalled them.
I also removed and reinstalled the ios platform with ionic platform rm/add ios
.
I am stuck with this.
The iPhone (6+) is on iOS 10.
I am using ionic 1, and the last ionic CLI.
EDIT: I removed all plugins one by one, and its seems that the problem is due to cordova-plugin-network-information and cordova-plugin-device.
Process 663 detached
(lldb)
(node:26790) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
14 030280 warn Native: deviceready did not fire within 2000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
15 030605 info [object Object]
16 033286 log deviceready has not fired after 5 seconds.
17 033290 log Channel not fired: onCordovaInfoReady
18 033293 log Channel not fired: onCordovaConnectionReady
19 363977 log DEVICE READY FIRED AFTER, 32259, ms
My run.js, AppCtrl.js and the controller of my main view are encapsultaed in $ionicPlatform.ready(function () {..});`
My content security policy is:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; connect-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ws: *;">
This seems to be a common issue with Ionic framework and there could be multiple reasons for it. One reason could be some issue with the plugin you use or could also be due to some issue in the platform folder. There seems to be an open issue on this in Ionic CLI project.
Following could be the possible fixes for this issue:
You can also have a look at this link
Hope this should help.
I added Thanks for your response @baviskarmitesh. But I had to add
gap
to the content security policy and now it seems to work.I added
data: gap: https://ssl.gstatic.com 'unsafe-eval'
afterdefault-src *
into my content security policy in my index.html file, like this:And now deviceready fires quickly with all my plugins.