我正在寻找一种方法来检测用户何时摇动他们的设备以触发我的 native react 应用程序中的功能。我可能会使用 react-native-sensors 中的“加速器”传感器。有没有人有 build 这样的东西的经验?任何指导将不胜感激。
https://react-native-sensors.github.io/docs/API.html
import { accelerometer } from "react-native-sensors";
const subscription = accelerometer.subscribe(({ x, y, z, timestamp }) =>
console.log({ x, y, z, timestamp })
);
最佳答案
有几个选项,结帐 react-native-shake例如。
关于android - 使用 react-native-sensors 检测摇动设备事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53890469/