Device API
Device API
Vibration
vibrateShort(options)
Triggers a short vibration (15ms).
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | - | Vibration intensity ('heavy' | 'medium' | 'light') |
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
TudadaSDK.vibrateShort({
type: 'medium',
success: () => console.log('Vibration triggered'),
});
vibrateLong(options)
Triggers a long vibration (400ms).
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
TudadaSDK.vibrateLong({
success: () => console.log('Long vibration triggered'),
});
Keyboard
showKeyboard(options)
Displays the virtual keyboard.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
defaultValue | string | - | Default input value |
maxLength | number | - | Maximum input length |
multiple | boolean | - | Whether to allow multi-line input |
confirmHold | boolean | - | Whether to keep the keyboard open after confirm |
confirmType | string | - | Confirm button type ('done' | 'next' | 'search' | 'go' | 'send') |
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
TudadaSDK.showKeyboard({
defaultValue: '',
maxLength: 100,
multiple: false,
confirmHold: false,
confirmType: 'done',
success: () => console.log('Keyboard shown'),
});
hideKeyboard()
Hides the virtual keyboard.
TudadaSDK.hideKeyboard();
onKeyboardInput(callback) / offKeyboardInput(callback?)
Registers/unregisters a keyboard input event listener.
Callback Parameters:
| Field | Type | Description |
|---|---|---|
value | string | Current input value |
TudadaSDK.onKeyboardInput((res) => {
console.log('Current input:', res.value);
});
// Remove all listeners
TudadaSDK.offKeyboardInput();
// Remove specific listener
TudadaSDK.offKeyboardInput(myFn);
onKeyboardConfirm(callback) / offKeyboardConfirm(callback?)
Registers/unregisters a keyboard confirm button click event listener.
Callback Parameters:
| Field | Type | Description |
|---|---|---|
value | string | Input value at confirmation |
TudadaSDK.onKeyboardConfirm((res) => {
console.log('Confirmed:', res.value);
});
TudadaSDK.offKeyboardConfirm();
onKeyboardComplete(callback) / offKeyboardComplete(callback?)
Registers/unregisters a keyboard input completion event listener.
Callback Parameters:
| Field | Type | Description |
|---|---|---|
value | string | Input value at completion |
TudadaSDK.onKeyboardComplete((res) => {
console.log('Complete:', res.value);
});
TudadaSDK.offKeyboardComplete();