How to detect system time change



Is there a way in ionic 2 to detect that the user has changed the system time while the app is running both for Android and iOS.



Hi. The first idea that comes to my mind is making an Observable that runs in a given interval. Don’t know if there’s a way to make this on a cleaner way, something like capturing a system event or something like that.
IMHO using an Observable to solve this could possibly lead to memory leaks if you’re not careful enough.
Best regards.


Interesting question, I would see if there is any kind of system notification/event broadcast when the system time is changed.

How do native apps handle this? Maybe you need a Cordova plugin that does the same and forwards the information to your Ionic app.


I could not find any cordova plugin that could serve this purpose. How can one listen to native events?


You could either create your own cordova plugin to handle this, or you could try this plugin:
cordova-plugin-intent in combination with the android.intent.action.TIME_SET intent.

Not sure how well the plugin works or anything, but there you go.


SigmundFroyd, thanks. This could be a good starting point, I will try it and post my findings.


Excuse me, could you solve the problem?


Unfortunately I couldn’t. This was beyond my ionic skills.