my.startDeviceMotionListening

Start listening for changes in the device's orientation.

Supported types of mini programs: DSL, H5+

Parameters

Property

Type

Default

Required

Description

interval

String

normal

No

The execution frequency of the callback function that listens for device orientation change events.

Valid values:

game: The callback frequency suitable for updating games, approximately once every 20 ms.

ui: The callback frequency suitable for updating the UI, approximately once every 60 ms.

normal: The standard callback frequency, approximately once every 200 ms.

success

Function

-

No

Callback function upon call success.

fail

Function

-

No

Callback function upon call failure.

complete

Function

-

No

Callback function upon call completion, regardless of success or failure.

Error codes

Error code

Error message

Further action

1001

The system doesn't support the relevant capabilities.

Try again with a different device.

Sample code

DSL

copy
my.startDeviceMotionListening({
  interval: 'normal',
  success: function (res) {
    console.log(res);
  },
  fail: function (err) {
    console.log(err);
  }
});

H5+

copy
AlipayJSBridge.call('startDeviceMotionListening', {}, function (res) {
    console.log(res);
});