react-native-check-device-auto-time
v0.1.0
Published
A React Native library to check if the device's automatic time setting is enabled on both Android and iOS platforms using native code.
Downloads
7
Readme
react-native-check-device-auto-time
A React Native library to check if the device's automatic time setting is enabled on both Android and iOS platforms using native code.
Installation
Install the library:
npm install react-native-check-device-auto-time
or
yarn add react-native-check-device-auto-time
Link the native modules:
For React Native 0.60 and above, the linking is done automatically. For older versions, you might need to link the library manually:
react-native link react-native-check-device-auto-time
Usage
Import the library:
import CheckDeviceAutoTime from 'react-native-check-device-auto-time';
Use the
isAutomaticTimeEnabled
function in your React Native component:import React, { useEffect, useState } from 'react'; import { View, Text } from 'react-native'; import CheckDeviceAutoTime from 'react-native-check-device-auto-time'; const App = () => { const [isAutoTimeEnabled, setIsAutoTimeEnabled] = useState(false); useEffect(() => { const checkAutoTime = async () => { const isEnabled = await CheckDeviceAutoTime.isAutomaticTimeEnabled(); setIsAutoTimeEnabled(isEnabled); }; checkAutoTime(); }, []); return ( <View> <Text>Automatic Time Enabled: {isAutoTimeEnabled ? 'Yes' : 'No'}</Text> </View> ); }; export default App;
License
This project is licensed under the MIT License. See the LICENSE file for details.