mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
Accelerometer event fix for Ios 13+ (#6585)
This commit is contained in:
@@ -72,7 +72,16 @@ export class SystemEvent extends EventTarget {
|
||||
if (EDITOR) {
|
||||
return;
|
||||
}
|
||||
inputManager.setAccelerometerEnabled(isEnabled);
|
||||
|
||||
// for iOS 13+
|
||||
if (isEnabled && window.DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === 'function') {
|
||||
DeviceMotionEvent.requestPermission().then(response => {
|
||||
console.log(`Device Motion Event request permission: ${response}`);
|
||||
inputManager.setAccelerometerEnabled(response === 'granted');
|
||||
});
|
||||
} else {
|
||||
inputManager.setAccelerometerEnabled(isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user