A simple React Native module to access Android's native system time.
$ npm install react-native-system-clock --save
$ react-native link react-native-system-clock
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNSystemClockPackage;
to the imports at the top of the file - Add
new RNSystemClockPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-system-clock' project(':react-native-system-clock').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-system-clock/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-system-clock')
import RNSystemClock from '@celo/react-native-system-clock'
await RNSystemClock.getDeviceTime()