Ionic 5 + Angular + Capacitor + Motion 在真实 Android 设备上不触发监听器

问题描述 投票:0回答:1

我正在尝试检测平板电脑/智能手机的运动/旋转(加速),但无法让它在真正的 Android 设备上运行。 我正在使用:

  • 离子5
  • 角度
  • 电容器
  • 运动

我遇到的问题与这个问题(在IOS上)非常相似,对此我们还没有最终的想法。

  • 使用模拟器,我看到我的 console.log 跟踪(顺便说一句,奇怪的是,即使我不使用模拟器 X Y Z 加速参数,加速日志也会连续触发。仅当我旋转模拟器时才会触发旋转...)
  • 使用真实设备(Samsung XCover 4S / android 9、Galaxy Tab 2 / android 7),在向各个方向移动平板电脑并更改其方向时,我没有得到任何痕迹。

我知道 iOS 需要“需要权限请求”,但我认为 Android 应该可以开箱即用。 如果有任何想法或指示可以帮助我解决这个问题,我将不胜感激;) 在 home.page.ts 中,我有:

ngAfterViewInit() { console.log("Before adding Motion Event Listener..."); const { Motion } = Capacitor.Plugins; Motion.addListener('accel', (event) => { console.log("!!! Acceleration Event !!!", event); }); Motion.addListener('orientation', (event) => { console.log("!!! Orientation Event !!!", event); }); console.log("After adding Motion Event Listener..."); }


android angular capacitor ionic5 motion
1个回答
0
投票
here

一旦手机浏览器信任我的网站,传感器就开始工作!

© www.soinside.com 2019 - 2024. All rights reserved.