1

Ionic v1 app needs to check if the Mobile Device (Android or iOS) has Automatic Time Zone enabled, how can I do that? I imagine it's done using ngCordova.

For some actions, Automatic Time Zone has to be enabled so the server will receive real date and time instead of fake ones. I won't allow the user to proceed if it's disabled.

Edson Horacio Junior
  • 3,033
  • 2
  • 29
  • 50
  • 1
    You could be a hero and write a plugin that allows the cordova community to access `android.provider.Settings.Global`. Last time I checked one doesn't exist. The better option for your issue is to just use unix time and never have to worry about timezones again. – BShaps Jul 06 '18 at 01:27
  • @BShaps I'm on my way to do that plugin! – Edson Horacio Junior Jul 06 '18 at 12:46
  • @BShaps bytheway, even if I use unix time, i'm still letting the user fake his date and time settings and that is a problem for me. – Edson Horacio Junior Jul 06 '18 at 12:47

1 Answers1

0

I have created this ngcordova plugin to do that, at the moment it only supports Android. iOS is not supported because it doesn't expose iPhone's Date and Time settings programatically.

Usage

window.VerifyAutomaticDateTimeZone.isAutomaticChecked(function(isIt){
  if (isIt == 'true') {
        // do something
    } else {
        // do something else
    }
});

In case window.VerifyAutomaticDateTimeZone is undefined, wrap the call with $ionicPlatform.ready or ionic.Platform.ready

$ionicPlatform.ready(function(){
    // code here...
});
Edson Horacio Junior
  • 3,033
  • 2
  • 29
  • 50