【问题标题】:Nativescript real device date and timeNativescript 真实设备日期和时间
【发布时间】:2019-05-17 07:35:57
【问题描述】:

有没有办法获取设备的日期和时间?自动的。如果用户禁用自动输入日期和时间并选择他自己的日期和时间,它会使我的应用程序崩溃。我也在使用 firebase

【问题讨论】:

    标签: javascript angular firebase nativescript


    【解决方案1】:

    在 iOS 上无法检测到该信息,但在 Android 上您可以做到这一点。

    if (application.android) {
            if (android.provider.Settings.Global.getInt(application.android.context.getContentResolver(), android.provider.Settings.Global.AUTO_TIME, 0) !== 1) {
                console.log("Date / Time preference is not set to auto!!!");
            }
        }
    

    在 iOS 上,唯一的选择可能是使用简单的 api 将本地日期时间与服务器的日期时间进行比较,确保包含时区信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 2018-06-08
      • 1970-01-01
      • 2017-12-05
      • 2019-09-16
      • 2014-03-09
      相关资源
      最近更新 更多