且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

React Native:如何检测设备锁定/解锁事件?

更新时间:2021-08-19 02:40:41

从那天起我就找不到任何方法在 React Native 中检测锁定/解锁事件.

Since that day I couldn't find any way to detect Lock/Unlock event in React native.

解决方案:

  1. 我们在 Android 和 iOS创建了示例模块(本机代码以获得锁定/解锁事件)
  2. 使用Android studio/XCode,我们导出React 原生模块
  3. React Native
  4. 中导入这些模块
  1. We've created sample modules in Android and iOS separate (Native code to get Lock/Unlock events)
  2. Using Android studio / XCode we've exported as React native modules
  3. Imported these modules in React native

它对我们来说很好.

希望对您有所帮助.