calibrateTimeWithNtp method
传入 NTP Server 地址校准 SDK 时间. 您可以根据您用户所在地传入访问速度较快的 NTP Server 地址, 例如 time.asia.apple.com SDK 默认情况下会等待 3 秒,去获取时间偏移数据,并用该偏移校准之后的数据. 如果在 3 秒内未因网络原因未获得正确的时间偏移,本次应用运行期间将不会再校准时间.
可用的 NTP 服务器地址Implementation
@override
Future<void> calibrateTimeWithNtp(String ntpServer) async {
try {
methodChannel.invokeMethod('calibrateTimeWithNtp', {
'ntpServer': ntpServer,
});
} on PlatformException catch (e) {
print('calibrateTimeWithNtp fail: ${e.message}');
}
}