playHaptic
Note
Please contact Zalopay Team to be granted permission to use this functionality.Description
Trigger vibration on the device
Warning: Each Android device can only use some of the types listed in the table below.
Please refer to detail document of Android, iOS to understand further about each type:
Equivalence of each type value across different OS:
type | Android | iOS |
---|---|---|
'LightTap' | { constant: 3 } | { type: 'feedback', submode: 0, intensity: 0.2 } |
'MediumTap' | { constant: 6 } | { type: 'feedback', submode: 1, intensity: 0.5 } |
'HeavyTap' | { constant: 0 } | { type: 'feedback', submode: 2, intensity: 0.8 } |
'Selection' | { constant: 4 } | { type: 'selection' } |
'Success' | { constant: 16 } | { type: 'notification', submode: 0 } |
'Error' | { constant: 17 } | { type: 'notification', submode: 2 } |
Parameters
Param | Data type | Required | Description |
---|---|---|---|
type | string | No | (ZPA) The device's haptic type. See detail of each haptic type across each OS in the table above. |
milliseconds | number | No | (ZMP) The duration that the device vibrates. |
Return Value
N/A
Error Code
N/A
Sample Code and Sample Return Data
Sample Request:
window.zlpSdk.Device
.playHaptic({ type: 'LightTap', milliseconds: 1000 })
.then((response) => console.log(response))
.catch((error) => console.error(error.errorCode));
Sample Response:
{ data: {}, status: "success" }