It’s a Cordova plugin that provides true time of the device
For ios platform, the plugin is based on this library : https://github.com/instacart/TrueTime.swift , plugin provides an interface to communicate with this library
For android, the plugin itself takes care of the TrueTime library code
- To add this plugin to your project run the following command in the root folder:
cordova plugin add https://github.com/navroopsinghsandhu/TruetimePlugin - Then add the following code in www/index.js of your project
window.plugins.truetimePlugin.getTrueTime('pool.ntp.org', function(event) {
//This the success callback function
// "pool.ntp.org" can be replaced with any other NTP server url in the argument above //you can access the timestamp for now() using "event['callback']"
// please note that this timestamp comprises of t[3] + offset //t0 using "event['t0']"
//t1 using "event['t1']"
//t2 using "event['t2']"
//t3 using "event['t3']"
//delay using "event['delay']"
}, function(err) {
console.log('Uh oh.. ' + err);
});
To update the plugin run following two commands in your root and you're good to go for the build without any further changes:
- cordova plugin remove truetimeplugin
- cordova plugin add https://github.com/navroopsinghsandhu/TruetimePlugin