Where should ionic.Platform.ready be fired?


#1

I’ve integrated push notifications into my app and am wondering when ionic.Platform.ready() should be fired? I’m currently using it in my main module’s .run to get my push notification token. Is that the best place for it?

Can ionic.Platform.ready() be used in a service?

I would like to extract my push functions and ionic.Platform.device() functions to a separate service but am not sure if I can use ionic.Platform.ready() there or if I have to keep it in the .run and just make sure I call my services after ready fires.

Any insight would be appreciated.

Thanks!


#2

It is safe to run ionic.Platform.ready from anywhere in your code actually, think of it like jQuery’s $(document).ready.

I just updated ionic.Platform.ready’s description in the docs:

Please let me know if the update helps or what else it could use to explain it better. Thanks