# Device
# Calendar
# addPhoneRepeatCalendar
addPhoneRepeatCalendar(Object object)
Add a recurring event to the system calendar.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| title | string | Yes | Calendar event title | |
| startTime | number | Yes | Unix timestamp of the start time (seconds elapsed since January 1, 1970) | |
| allDay | boolean | No | Whether it is an all-day event, default is false | |
| description | string | No | Event description | |
| location | string | No | Event location | |
| endTime | string | No | Unix timestamp of the end time, default is the same as the start time | |
| alarm | boolean | No | Whether to set a reminder, default is true | |
| alarmOffset | number | No | Reminder offset in seconds, default is 0 which means remind at the start time | |
| repeatInterval | string | No | Recurrence interval, default is monthly | |
| repeatEndTime | number | No | Unix timestamp for when the recurrence ends, if not provided, it repeats indefinitely | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed on both success and failure) |
# addPhoneCalendar
addPhoneCalendar(Object object)
Add an event to the system calendar.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| title | string | Yes | Calendar event title | |
| startTime | number | Yes | Unix timestamp of the start time (seconds elapsed since January 1, 1970) | |
| allDay | boolean | No | Whether it is an all-day event, default is false | |
| description | string | No | Event description | |
| location | string | No | Event location | |
| endTime | string | No | Unix timestamp of the end time, default is the same as the start time | |
| alarm | boolean | No | Whether to set a reminder, default is true | |
| alarmOffset | number | No | Reminder offset in seconds, default is 0 which means remind at the start time | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed on both success and failure) |
# Clipboard
# setClipboardData
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38, requires Extension SDK. Starting from iOS version 2.35.13, Android 2.35.9, this API needs to be injected by the Host-App, removed from the SDK.
setClipboardData(Object object)
Set the content of the system clipboard.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | string | Yes | Content of the clipboard | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed on both success and failure) |
Sample Code
ft.setClipboardData({
data: 'data',
success(res) {
ft.getClipboardData({
success(res) {
console.log(res.data) // data
}
})
}
})
# getClipboardData
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38, requires Extension SDK. Starting from iOS version 2.35.13, Android 2.35.9, this API needs to be injected by the Host-App, removed from the SDK.
getClipboardData(Object object)
Get the content of the system clipboard.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed on both success and failure) |
object.success callback function
Parameters
Object object
| Property | Type | Description |
|---|---|---|
| data | string | Content of the clipboard |
Sample Code
ft.getClipboardData({
success(res) {
console.log(res.data)
}
})
# Network
# onNetworkStatusChange
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38 onwards
onNetworkStatusChange(function callback)
Listens for network status change events.
Parameters
function callback
Callback function for network status change events.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| isConnected | boolean | Whether there is a current network connection |
| networkType | string | Network type |
Valid values for res.networkType
| Value | Description |
|---|---|
| wifi | Wi-Fi network |
| 2g | 2G network |
| 3g | 3G network |
| 4g | 4G network |
| unknown | Unknown network |
| none | No network |
Sample Code
ft.onNetworkStatusChange(function(res) {
console.log(res.isConnected)
console.log(res.networkType)
})
# offNetworkStatusChange
offNetworkStatusChange(function callback)
Cancels listening for network status change events. If the parameter is empty, all event listeners are canceled.
Parameters
function callback
Callback function for network status change events.
# getNetworkType
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38 onwards
getNetworkType(Object object)
Gets the network type.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| networkType | string | Network type |
Valid values for res.networkType
| Value | Description |
|---|---|
| wifi | Wi-Fi network |
| 2g | 2G network |
| 3g | 3G network |
| 4g | 4G network |
| unknown | Unknown network |
| none | No network |
Sample Code
ft.getNetworkType({
success(res) {
const networkType = res.networkType
}
})
# getLocalIPAddress
Supported from Base Library 3.2.2, iOS version 2.43.2, Android version 2.43.2
Gets the local area network IP address.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| errMsg | string | Error message |
| localip | string | Local LAN IP address |
| netmask | string | Local LAN subnet mask |
Sample Code
ft.getLocalIPAddress({
success(res) {
console.log(res.localip)
}
})
# Encryption
# getRandomValues
Gets cryptographically secure random numbers.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| length | number | Yes | Integer, number of bytes to generate random numbers, maximum 1048576 | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object object
| Property | Type | Description |
|---|---|---|
| randomValues | ArrayBuffer | Random number content, length equals to the number of bytes passed in |
Sample Code
ft.getRandomValues({
length: 6, // Generate random numbers with a length of 6 bytes
success: res => {
console.log(ft.arrayBufferToBase64(res.randomValues)) // Convert to base64 string and print
}
})
# Screen
# setVisualEffectOnCapture
Supported from Base Library 2.12.16, Android version 2.37.1
setVisualEffectOnCapture(Object object)
Sets the screen behavior during screenshot/recording, only supported on Android.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| visualEffect | string | none | Yes | Behavior during screenshot/recording, only supports none / hidden. Passing hidden hides the screen during screenshot/recording |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# setScreenBrightness
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38 onwards
setScreenBrightness(Object object)
Sets the screen brightness.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| value | number | Yes | Screen brightness value, range 0 ~ 1. 0 is the darkest, 1 is the brightest | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# setKeepScreenOn
Supported from Base Library 1.3.9, iOS SDK 2.1.23, Android SDK 2.1.38 onwards
setKeepScreenOn(Object object)
Sets whether to keep the screen always on.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| keepScreenOn | boolean | Yes | Whether to keep the screen always on | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Sample Code
// Example code here
ft.setKeepScreenOn({
keepScreenOn: true
})
# onUserCaptureScreen
onUserCaptureScreen(function callback)
Listens for user-initiated screenshot events. Triggered when the user takes a screenshot using the system screenshot button. Only one listener can be registered.
Parameters
function callback
Callback function for user-initiated screenshot events.
Example Code
ft.onUserCaptureScreen(function(res) {
console.log('The user has taken a screenshot')
})
# onScreenRecordingStateChanged
onScreenRecordingStateChanged(function callback)
Listens for user screen recording events, triggered when the user records the screen. Only supported on iOS.
Parameters
function callback
Callback function for user-initiated screen recording events.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| state | string | Value is either "start" or "stop". "start": recording started; "stop": recording stopped |
Example Code
ft.onScreenRecordingStateChanged(function(res) {
console.log(res.state)
})
# offUserCaptureScreen
offUserCaptureScreen(function callback)
Cancels the listening of user-initiated screenshot events.
Parameters
function callback
Callback function for user-initiated screenshot events.
# offScreenRecordingStateChanged
offScreenRecordingStateChanged(function callback)
Removes the listener for user screen recording events.
Parameters
function callback
Callback function for user-initiated screenshot events.
If no parameter is passed, all listener functions will be removed.
# getScreenRecordingState
Supported from Base Library version 2.12.16, iOS version 2.37.1, Android not supported.
getScreenRecordingState(Object object)
Queries whether the user is currently recording the screen.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| state | string | Screen recording status, value is either "on" or "off" |
# getScreenBrightness
Supported from Base Library version 1.3.9, iOS SDK version 2.1.23, Android SDK version 2.1.38.
getScreenBrightness(Object object)
Gets the screen brightness.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| value | number | Screen brightness value, range 0 ~ 1, 0 is dimmest, 1 is brightest |
# Keyboard
# onKeyboardHeightChange
onKeyboardHeightChange(function callback)
Listens for changes in keyboard height.
Parameters
function callback
Parameters
object res
| Property | Type | Description |
|---|---|---|
| height | number | Keyboard height |
Example Code
ft.onKeyboardHeightChange(res => {
console.log(res.height)
})
# offKeyboardHeightChange
offKeyboardHeightChange(function callback)
Cancels listening for keyboard height change events.
Parameters
function callback
Callback function for keyboard height change events.
# hideKeyboard
hideKeyboard(Object object)
Manually hides the keyboard after it has been brought up by focusing on an input or textarea element.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
Example Code
ft.hideKeyboard({
complete: res => {
console.log('hideKeyboard res', res)
}
})
# getSelectedTextRange
getSelectedTextRange(Object object)
After focusing on an input or textarea, retrieves the cursor position within the text field. Note: This interface only works when the input is focused.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| start | number | Starting position of the text field cursor |
| end | number | Ending position of the text field cursor |
Example Code
ft.getSelectedTextRange({
complete: res => {
console.log('getSelectedTextRange res', res.start, res.end)
}
})
})
# Phone
# makePhoneCall
Supported from Base Library version 1.3.9, iOS SDK version 2.1.23, Android SDK version 2.1.38.
makePhoneCall(Object object)
Makes a phone call. Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| phoneNumber | string | Yes | The phone number to be dialed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Sample Code
ft.makePhoneCall({
phoneNumber: '1340000' // For example only, not a real phone number
})
# Accelerometer
# stopAccelerometer
stopAccelerometer(Object object)
Stops listening to accelerometer data.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Sample Code
ft.stopAccelerometer()
# startAccelerometer
startAccelerometer(Object object)
Starts listening to accelerometer data.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| interval | string | normal | No | Execution frequency of the accelerometer data callback |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Valid values for object.interval
| Value | Description |
|---|---|
| game | Suitable for updating games, around 20ms per call |
| ui | Suitable for updating UI, around 60ms per call |
| normal | Normal frequency, around 200ms per call |
Sample Code
ft.startAccelerometer({
interval: 'game'
})
# onAccelerometerChange
onAccelerometerChange(function callback)
Listens to accelerometer data events. Frequency depends on the interval parameter of ft.startAccelerometer(), and monitoring starts automatically after the API is called.
Parameters
function callback
Callback function for accelerometer data events
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| x | number | X-axis |
| y | number | Y-axis |
| z | number | Z-axis |
Sample Code
ft.onAccelerometerChange(callback)
# offAccelerometerChange
offAccelerometerChange(function callback)
Stops listening to accelerometer data events. If the parameter is empty, all event listeners will be removed.
Parameters
function callback
Callback function for accelerometer data events
# Compass
# stopCompass
stopCompass(Object object)
Stops listening to compass data.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Sample Code
ft.stopCompass()
# startCompass
startCompass(Object object)
Starts listening to compass data.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Sample Code
ft.startCompass()
# onCompassChange
onCompassChange(function callback)
Listens to compass data change events. Frequency: 5 times/second. Monitoring starts automatically after the API is called, and can be stopped using ft.stopCompass.
Parameters
function callback
Callback function for compass data change events
Parameters
Object object
| Property | Type | Description |
|---|---|---|
| direction | number | Degrees of facing direction |
| accuracy | number/string | Accuracy |
Sample Code
ft.onCompassChange(callback)
Differences in accuracy between iOS/Android
Due to platform differences, the value of accuracy differs between iOS and Android.
- iOS:
accuracyis a number type value indicating deviation from magnetic north. 0 means the device is pointing to magnetic north, 90 means east, 180 means south, and so on. - Android:
accuracyis a string type enumeration value.
| Value | Description |
|---|---|
| high | High precision |
| medium | Medium precision |
| low | Low precision |
| no-contact | Unreliable, sensor connection lost |
| unreliable | Unreliable, unknown reason |
| unknow ${value} | Unknown accuracy enumeration value, meaning that the value returned by this Android system is not a standard accuracy enumeration value |
# offCompassChange
offCompassChange(function callback)
Stops listening to compass data change events. If the parameter is empty, all event listeners will be removed.
Parameters
function callback
Callback function for compass data change events
# Device Orientation
# stopDeviceMotionListening
stopDeviceMotionListening(Object object)
Stops listening to changes in device orientation.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
# startDeviceMotionListening
startDeviceMotionListening(Object object)
Starts listening to changes in device orientation.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| interval | string | normal | No | Execution frequency of the device orientation change callback |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Valid values for object.interval
| Value | Description |
|---|---|
| game | Callback frequency suitable for updating games, approximately 20ms per time |
| ui | Callback frequency suitable for updating UI, approximately 60ms per time |
| normal | Normal callback frequency, approximately 200ms per time |
# onDeviceMotionChange
onDeviceMotionChange(function callback)
Listens for device orientation change events. The frequency depends on the interval parameter of ft.startDeviceMotionListening(). Listening can be stopped using ft.stopDeviceMotionListening().
Parameters
function callback
Callback function for device orientation change events
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| alpha | number | When the mobile X/Y axis coincides with the Earth's X/Y axis, the angle of rotation around the Z-axis is alpha, with a range of [0, 2*PI). Counterclockwise rotation is positive. |
| beta | number | When the mobile Y/Z axis coincides with the Earth's Y/Z axis, the angle of rotation around the X-axis is beta. Range: [-1*PI, PI). Positive when the top tilts towards the Earth's surface or towards the user. |
| gamma | number | When the mobile X/Z axis coincides with the Earth's X/Z axis, the angle of rotation around the Y-axis is gamma. Range: [-1*PI/2, PI/2). Positive when the right side tilts towards the Earth's surface. |
# offDeviceMotionChange
offDeviceMotionChange(function callback)
Cancels listening to device orientation change events. If the parameter is empty, all event listeners will be canceled.
Parameters
function callback
Callback function for device orientation change events
# Gyroscope
# stopGyroscope
stopGyroscope(Object object)
Stops listening to gyroscope data.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# startGyroscope
startGyroscope(Object object)
Starts listening to gyroscope data.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| interval | string | normal | No | Execution frequency of the gyroscope data callback function |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Valid values for object.interval
| Value | Description |
|---|---|
| game | Callback frequency suitable for updating games, approximately 20ms per time |
| ui | Callback frequency suitable for updating UI, approximately 60ms per time |
| normal | Normal callback frequency, approximately 200ms per time |
# onGyroscopeChange
onGyroscopeChange(function callback)
Listens for gyroscope data change events. The frequency depends on the interval parameter of ft.startGyroscope(). Listening can be stopped using ft.stopGyroscope().
Parameters
function callback
Callback function for gyroscope data change events
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| x | number | Angular velocity along the x-axis |
| y | number | Angular velocity along the y-axis |
| z | number | Angular velocity along the z-axis |
# offGyroscopeChange
offGyroscopeChange(function callback)
Cancels listening to gyroscope data change events.
Parameters
function callback
Callback function for gyroscope data change events
# Memory
# onMemoryWarning
onMemoryWarning(function callback)
Listens for memory warning events.
Parameters
function listener
Listener function for memory warning events
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| level | number | Memory warning level, implemented only on Android |
Valid values for res.level
| Value | Description |
|---|---|
| 5 | TRIM_MEMORY_RUNNING_MODERATE |
| 10 | TRIM_MEMORY_RUNNING_LOW |
| 15 | TRIM_MEMORY_RUNNING_CRITICAL |
# offMemoryWarning
offMemoryWarning(function callback)
Removes the listener function for memory warning events.
Parameters
function listener
Listener function for memory warning events
# Scanning
# scanCode
Supported from Base Library 1.3.9, iOS SDK 2.1.23, and Android SDK 2.1.38 onwards
scanCode(Object object)
Invokes the client-side scanning interface to scan codes.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| onlyFromCamera | boolean | false | No | Whether scanning is only allowed from the camera, disallowing image selection from the photo album |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call (when authorization fails, returns error message: fail unauthorized User has not granted camera permission) | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
object.success callback function
Parameters
Object res
Sample Code
// Allows scanning from both camera and photo album
ft.scanCode({
success(res) {
console.log(res)
}
})
// Only allows scanning from the camera
ft.scanCode({
onlyFromCamera: true,
success(res) {
console.log(res)
}
})
Note
- API Authorization Failure (iOS):
- If the user denies authorization, it returns an error message: unauthorized, User has not granted camera permission.
- If the Host-App prohibits Mini-Programs from actively requesting permissions, it returns an error message: unauthorized disableauthorized, SDK is prohibited from requesting camera permissions.
- API Authorization Failure (Android):
- If the user denies authorization, it returns an error message: fail unauthorized User has not granted camera permission.
- If the Host-App prohibits Mini-Programs from actively requesting permissions, it returns an error message: unauthorized disableauthorized SDK is prohibited from initiating permission requests.
# Vibration
# vibrateShort
Supported from Base Library 1.3.9, iOS SDK 2.1.23, and Android SDK 2.1.38 onwards
vibrateShort(Object object)
Causes the phone to vibrate for a short period (15 ms). Effective only on iPhone 7 / 7 Plus and above, as well as Android devices.
Parameters
Object object
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| type | String | Yes | Vibration intensity type, valid values are: heavy, medium, light. iOS: supported from 2.39.11; Android: supported from 2.25.1 | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call (when authorization fails, returns error message: fail unauthorized User has not granted vibration permission) | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Note
- API Authorization Failure (Android):
- If the user denies authorization, it returns an error message: unauthorized User has not granted vibration permission.
- If the Host-App prohibits Mini-Programs from actively requesting permissions, it returns an error message: unauthorized disableauthorized SDK is prohibited from initiating permission requests.
# vibrateLong
Base Library 1.3.9 and above, iOS SDK 2.1.23 and above, Android SDK 2.1.38 and above supported
vibrateLong(Object object)
Causes the phone to vibrate for a longer period of time (400 ms).
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call (when authorization fails, returns error message: fail unauthorized user did not grant vibration permission) | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Note
- Authorization failure (Android):
- If the user denies authorization, it will return an error message: unauthorized user did not grant vibration permission
- If the Host-App prohibits Mini-Programs from actively requesting permissions, it will return an error message: unauthorized disableauthorized SDK was prohibited from initiating permission requests
- iOS:
- The long vibration effect requires iPhone --> Settings ---> Vibration in Ring Mode, Vibration in Silent Mode to be enabled; otherwise, there will be no vibration effect.
# SMS
# sendSms
Base Library 3.5.1 and above, iOS SDK 2.46.1 and above, Android SDK 2.46.1 and above supported
sendSms(Object object)
Brings up the phone's SMS sending interface.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| phoneNumber | string | No | Pre-filled phone number on the SMS panel | |
| content | string | No | Pre-filled content on the SMS panel | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
# Bluetooth - General
# stopBluetoothDevicesDiscovery
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependent on Extension SDK. Starting from 2.35.7, the Bluetooth module is independent and requires separate dependency on BluetoothSDK.
stopBluetoothDevicesDiscovery(Object object)
Stops searching for nearby Bluetooth peripheral devices. If the required Bluetooth device has been found and further searching is unnecessary, it is recommended to call this interface to stop Bluetooth searching.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below system version 4.3 |
| 10012 | operation timeout | Connection timeout |
| 10013 | invalid data | Connection deviceId is empty or incorrectly formatted |
# startBluetoothDevicesDiscovery
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependent on Extension SDK.
startBluetoothDevicesDiscovery(Object object)
Starts searching for nearby Bluetooth peripheral devices.
This operation consumes significant system resources. It is recommended to call ft.stopBluetoothDevicesDiscovery to stop searching as soon as the desired device is found.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| services | Array.string | No | List of UUIDs of the main services of the Bluetooth devices to search for (supports 16/32/128-bit UUID). Some Bluetooth devices broadcast their main service UUIDs. If this parameter is set, only devices broadcasting the corresponding UUID will be searched. It is recommended to filter out irrelevant Bluetooth devices using this parameter. | |
| allowDuplicatesKey | boolean | false | No | Whether to allow repeated reporting of the same device. If allowed, the onBlueToothDeviceFound method will report the same device multiple times, but with different RSSI values. |
| interval | number | 0 | No | Interval for reporting devices, in milliseconds. A value of 0 means new devices are reported immediately upon discovery; other values report according to the specified interval. |
| powerLevel | string | medium | No | Scan mode, higher scan speed consumes more power. |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Valid values for object.powerLevel
| Value | Description | Minimum Version |
|---|---|---|
| low | Low | |
| medium | Medium | |
| high | High |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below system version 4.3 |
| 10012 | operation timeout | Connection timeout |
| 10013 | invalid data | Connection deviceId is empty or incorrectly formatted |
# openBluetoothAdapter
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependent on Extension SDK.
openBluetoothAdapter(Object object)
Initializes the Bluetooth module. On iOS, when enabling host/peripheral (peripheral device) mode, it needs to be called separately for each mode, specifying the corresponding mode.
Parameters
Object object
| Property | Type | Default Value | Required | Description | Minimum Version |
|---|---|---|---|---|---|
| mode | string | central | No | Bluetooth mode, can act as host/peripheral device, only required for iOS. | |
| success | function | No | Callback function for successful API call | ||
| fail | function | No | Callback function for failed API call | ||
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Valid values for object.mode
| Value | Description | Minimum Version |
|---|---|---|
| central | Host mode | |
| peripheral | Peripheral (device) mode |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below system version 4.3 |
| 10012 | operation timeout | Connection timeout |
| 10013 | invalid data | Connection deviceId is empty or incorrectly formatted |
state parameter returned by object.fail callback function (iOS only)
| Status Code | Description |
|---|---|
| 0 | Unknown |
| 1 | Resetting |
| 2 | Not supported |
| 3 | Unauthorized |
| 4 | Not enabled |
Note
- Other Bluetooth-related APIs must be used after calling
openBluetoothAdapter. Otherwise, the API will return an error (errCode=10000). - In cases where the user’s Bluetooth switch is off or the phone does not support Bluetooth functionality, calling
openBluetoothAdapterwill return an error (errCode=10001), indicating that the phone's Bluetooth functionality is unavailable. At this point, the Mini-Program Bluetooth module has been initialized, and you can listen for changes in the phone's Bluetooth status viaonBluetoothAdapterStateChange, or call all Bluetooth module APIs.
Note
- Authorization failure (iOS):
- If the Host-App prohibits Mini-Programs from actively requesting permissions, it will return an error message: unauthorized disableauthorized, SDK was prohibited from applying for Bluetooth permissions.
# onBluetoothDeviceFound
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, dependent on Extension SDK. onBluetoothDeviceFound(function callback) Listens for events when new devices are discovered.
Parameters
function callback
Callback function for the event when new devices are discovered.
Parameters
object res
| Property | Type | Description |
|---|---|---|
| devices | Array.Object | List of newly discovered devices |
Structure of res.devices
| Property | Type | Description |
|---|---|---|
| name | string | Bluetooth device name, some devices may not have one |
| deviceId | string | Bluetooth device id |
| RSSI | number | Signal strength of the current Bluetooth device, in dBm |
| advertisData | ArrayBuffer | ManufacturerData segment in the current Bluetooth device's broadcast data section. |
| advertisServiceUUIDs | Array.string | ServiceUUIDs segment in the current Bluetooth device's broadcast data section |
| localName | string | LocalName segment in the current Bluetooth device's broadcast data section |
| serviceData | Object | ServiceData segment in the current Bluetooth device's broadcast data section |
# Note
- If a device is returned in the
onBluetoothDeviceFoundcallback, this device will be added to the array obtained by thegetBluetoothDevicesinterface. - On Android, some models require location permission to discover devices. Ensure that location permission is enabled.
- Repeated calls will override previous callbacks.
# onBluetoothAdapterStateChange
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK onBluetoothAdapterStateChange(function callback)
Listens for changes in the Bluetooth adapter state.
Parameters
function callback
Callback function for Bluetooth adapter state change events.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| available | boolean | Whether the Bluetooth adapter is available |
| discovering | boolean | Whether the Bluetooth adapter is in the scanning state |
Note Repeated calls will override previous callbacks.
# offBluetoothDeviceFound
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
Cancels listening for new device discovery events.
# offBluetoothAdapterStateChange
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
Cancels listening for Bluetooth adapter state change events.
# makeBluetoothPair
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
makeBluetoothPair(Object object)
Bluetooth pairing interface, only supported on Android.
In most cases (when a pin code or password needs to be specified), the system will take over the pairing process, and you can directly call createBLEConnection. This interface should only be used when developers do not want users to manually input the pin code and have confirmed through real-device testing that it works properly.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| pin | string | Yes | Pin code, in Base64 format | |
| timeout | number | 20000 | No | Timeout duration, in ms |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
# getConnectedBluetoothDevices
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
getConnectedBluetoothDevices(Object object)
Retrieves connected Bluetooth devices based on the primary service UUID.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| services | Array.string | Yes | List of primary service UUIDs of the Bluetooth device (supports 16/32/128-bit UUIDs) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| devices | Array.Object | List of discovered devices |
Structure of res.devices
| Property | Type | Description |
|---|---|---|
| name | string | Bluetooth device name, may not exist for some devices |
| deviceId | string | ID used to distinguish devices |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below Android 4.3 |
| 10012 | operation timed out | Connection timeout |
| 10013 | invalid data | Device ID is empty or incorrectly formatted |
# getBluetoothDevices
getBluetoothDevices(Object object)
Retrieves all Bluetooth devices discovered during the active period of the Bluetooth module, including devices currently connected to the local device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| devices | Array.Object | List of devices corresponding to UUIDs |
Structure of res.devices
| Property | Type | Description |
|---|---|---|
| name | string | Bluetooth device name, may not exist for some devices |
| deviceId | string | Bluetooth device ID |
| RSSI | number | Signal strength of the current Bluetooth device, in dBm |
| advertisData | ArrayBuffer | ManufacturerData segment in the broadcast data of the current Bluetooth device |
| advertisServiceUUIDs | Array.string | ServiceUUIDs segment in the broadcast data of the current Bluetooth device |
| localName | string | LocalName segment in the broadcast data of the current Bluetooth device |
| serviceData | Object | ServiceData segment in the broadcast data of the current Bluetooth device |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below Android 4.3 |
| 10012 | operation timed out | Connection timeout |
| 10013 | invalid data | Device ID is empty or incorrectly formatted |
# getBluetoothAdapterState
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
getBluetoothAdapterState(Object object)
Retrieves the status of the local Bluetooth adapter.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| discovering | boolean | Whether the device is currently scanning |
| available | boolean | Whether the Bluetooth adapter is available |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below Android 4.3 |
| 10012 | operation timed out | Connection timeout |
| 10013 | invalid data | Device ID is empty or incorrectly formatted |
# closeBluetoothAdapter
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
closeBluetoothAdapter(Object object)
Closes the Bluetooth module. Calling this method will disconnect all established connections and release system resources. It is recommended to use this method in conjunction with openBluetoothAdapter after completing Bluetooth operations.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for API call completion (executed regardless of success or failure) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not initialized | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection failed | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not supported | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not supported | Android-specific, BLE not supported below Android 4.3 |
| 10012 | operation timed out | Connection timeout |
| 10013 | invalid data | Device ID is empty or incorrectly formatted |
# Bluetooth - Low Energy Central Device
# writeBLECharacteristicValue
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
writeBLECharacteristicValue(Object object)
Writes binary data to the characteristic value of a Bluetooth Low Energy (BLE) device. Note: The characteristic must support the write operation for this call to succeed.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| serviceId | string | Yes | UUID of the service corresponding to the Bluetooth characteristic | |
| characteristicId | string | Yes | UUID of the Bluetooth characteristic | |
| value | ArrayBuffer | Yes | Binary value corresponding to the Bluetooth characteristic | |
| writeType | string | Yes | Write mode setting for the Bluetooth characteristic value. iOS prefers write, Android prefers writeNoResponse. | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
writeType
| Valid Values | Type |
|---|---|
| write | Forced write with response; throws an error if not supported |
| writeNoResponse | Forced write without response; throws an error if not supported |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter is unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported on systems below version 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | Connection deviceId is empty or incorrectly formatted |
# setBLEMTU
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
setBLEMTU(Object object)
Negotiates and sets the Maximum Transmission Unit (MTU) for Bluetooth Low Energy (BLE). Must be called after createBLEConnection is successfully invoked. Only effective on Android systems version 5.1 and above; iOS does not support due to system limitations.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| mtu | number | Yes | Maximum Transmission Unit. Valid range: (22, 512), in bytes | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
object.success callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| mtu | number | Final negotiated MTU value, consistent with the input parameter. Supported starting from Android client version 8.0.9. |
object.fail callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| mtu | number | Final negotiated MTU value. If negotiation fails, this parameter will not be present. Supported starting from Android client version 8.0.9. |
# readBLECharacteristicValue
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
readBLECharacteristicValue(Object object)
Reads binary data from the characteristic value of a Bluetooth Low Energy (BLE) device. Note: The characteristic must support the read operation for this call to succeed.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| serviceId | string | Yes | UUID of the service corresponding to the Bluetooth characteristic | |
| characteristicId | string | Yes | UUID of the Bluetooth characteristic | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter is unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported on systems below version 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | Connection deviceId is empty or incorrectly formatted |
Notes
- Concurrent calls may result in read failures.
- Information read by the interface needs to be retrieved in the callback registered with
onBLECharacteristicValueChange.
# onBLEConnectionStateChange
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
onBLEConnectionStateChange(function callback)
Listens for changes in the connection state of Bluetooth Low Energy (BLE). This includes events such as developers actively connecting or disconnecting, device loss, or abnormal disconnection.
Parameters
function callback
Callback function for changes in the BLE connection state.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| deviceId | string | Bluetooth device ID |
| connected | boolean | Whether the device is currently connected |
Notes
Repeated calls will override the previous callback.
# onBLECharacteristicValueChange
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
onBLECharacteristicValueChange(function callback)
Listens for changes in the characteristic value of a Bluetooth Low Energy (BLE) device. The notifyBLECharacteristicValueChange interface must be called first to receive notifications from the device.
Parameters
function callback
Callback function for changes in the BLE device's characteristic value.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| deviceId | string | Bluetooth device ID |
| serviceId | string | UUID of the service corresponding to the Bluetooth characteristic |
| characteristicId | string | UUID of the Bluetooth characteristic |
| value | ArrayBuffer | Latest value of the characteristic |
Notes
Repeated calls will override the previous callback.
# offBLEConnectionStateChange
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
Cancels listening for changes in the connection state of Bluetooth Low Energy (BLE).
# offBLECharacteristicValueChange
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
Cancels listening for changes in the characteristic value of a Bluetooth Low Energy (BLE) device.
# notifyBLECharacteristicValueChange
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
notifyBLECharacteristicValueChange(Object object)
Enables the notify functionality for changes in the characteristic value of a Bluetooth Low Energy (BLE) device, subscribing to the characteristic. Note: The characteristic must support notify or indicate for this call to succeed.
Additionally, notifyBLECharacteristicValueChange must be enabled before listening to the characteristicValueChange event.
Parameters
Object res
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| serviceId | string | Yes | UUID of the service corresponding to the Bluetooth characteristic | |
| characteristicId | string | Yes | UUID of the Bluetooth characteristic | |
| state | boolean | Yes | Whether to enable notify | |
| type | string | indication | No | Sets the characteristic subscription type. Valid values: notification and indication |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed whether the call succeeds or fails) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter is unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported on systems below version 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | Connection deviceId is empty or incorrectly formatted |
Notes
After a successful subscription, the device must actively update the characteristic's value to trigger the onBLECharacteristicValueChange callback.
On Android platforms, immediately calling writeBLECharacteristicValue after this interface succeeds may result in a system error 10008 on some devices.
# getBLEDeviceServices
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
getBLEDeviceServices(Object object)
Get all services (service) of a Bluetooth Low Energy (BLE) device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID. Must be connected via createBLEConnection beforehand | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when the API call ends (executed on both success and failure) |
object.success callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| services | Array.Object | List of device services |
Structure properties:
| Property | Type | Description |
|---|---|---|
| uuid | string | UUID of the Bluetooth device service |
| isPrimary | boolean | Whether this service is the primary service |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported below Android 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | DeviceId is empty or incorrectly formatted |
# getBLEDeviceRSSI
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
getBLEDeviceRSSI(Object object)
Get the signal strength (Received Signal Strength Indication, RSSI) of a Bluetooth Low Energy (BLE) device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when the API call ends (executed on both success and failure) |
object.success callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| RSSI | Number | Signal strength in dBm |
# getBLEDeviceCharacteristics
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
getBLEDeviceCharacteristics(Object object)
Get all characteristics (characteristic) of a specific service of a Bluetooth Low Energy (BLE) device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID. Must be connected via createBLEConnection beforehand | |
| serviceId | string | Yes | Bluetooth service UUID. Must first call getBLEDeviceServices to retrieve | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when the API call ends (executed on both success and failure) |
object.success callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| characteristics | Array.Object | List of device characteristics |
characteristics
| Structure Property | Type | Description |
|---|---|---|
| uuid | string | UUID of the Bluetooth device characteristic |
| properties | Object | Types of operations supported by this characteristic |
properties
| Structure Property | Type | Description |
|---|---|---|
| read | boolean | Whether this characteristic supports read operations |
| write | boolean | Whether this characteristic supports write operations |
| notify | boolean | Whether this characteristic supports notify operations |
| indicate | boolean | Whether this characteristic supports indicate operations |
| writeNoResponse | boolean | Whether this characteristic supports write without response |
| writeDefault | boolean | Whether this characteristic supports write with response |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported below Android 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | DeviceId is empty or incorrectly formatted |
# createBLEConnection
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
createBLEConnection(Object object)
Connect to a Bluetooth Low Energy (BLE) device.
If the Mini-Program previously searched for a Bluetooth device and successfully established a connection, you can directly pass the previously retrieved deviceId to attempt connecting to the device without performing another search.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| timeout | number | No | Timeout duration in ms; if not provided, no timeout will occur | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when the API call ends (executed on both success and failure) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported below Android 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | DeviceId is empty or incorrectly formatted |
Note
Ensure that createBLEConnection and closeBLEConnection are called as a pair whenever possible. On Android, repeatedly calling createBLEConnection may result in the system holding multiple connection instances for the same device, causing closeBLEConnection to not actually disconnect from the device.
Bluetooth connections may drop at any time. It is recommended to listen to the onBLEConnectionStateChange callback event and perform reconnection operations as needed when the Bluetooth device disconnects.
If data read/write operations are attempted on a device that is not connected or has been disconnected, error code 10006 will be returned, and reconnection is recommended.
# closeBLEConnection
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
closeBLEConnection(Object object)
Disconnect from a Bluetooth Low Energy (BLE) device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| deviceId | string | Yes | Bluetooth device ID | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when the API call ends (executed on both success and failure) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| -1 | already connected | Already connected |
| 10000 | not init | Bluetooth adapter not initialized |
| 10001 | not available | Current Bluetooth adapter unavailable |
| 10002 | no device | Specified device not found |
| 10003 | connection fail | Connection failed |
| 10004 | no service | Specified service not found |
| 10005 | no characteristic | Specified characteristic not found |
| 10006 | no connection | Current connection has been disconnected |
| 10007 | property not support | Current characteristic does not support this operation |
| 10008 | system error | All other system-reported exceptions |
| 10009 | system not support | Android-specific: BLE not supported below Android 4.3 |
| 10012 | operate time out | Connection timeout |
| 10013 | invalid_data | DeviceId is empty or incorrectly formatted |
# Bluetooth - Low Energy Peripheral Devices
# onBLEPeripheralConnectionStateChanged
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, depends on Extension SDK
onBLEPeripheralConnectionStateChanged(function callback)
Listen for events when the current peripheral device is connected or disconnected.
Parameters
Object object
Callback function for when the current peripheral device is connected or disconnected.
Parameters Object res
| Property | Type | Description |
|---|---|---|
| deviceId | String | ID of the device whose connection status has changed |
| serverId | String | UUID of the server |
| connected | Boolean | Current connection status |
# offBLEPeripheralConnectionStateChanged
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
Unlisten to the event of the current peripheral device being connected or disconnected.
# createBLEPeripheralServer
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
createBLEPeripheralServer(Object object)
Establish a local service as a Bluetooth Low Energy (BLE) peripheral server, multiple servers can be created.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
object.success callback function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| server | BLEPeripheralServer | Peripheral device's server. |
# BLEPeripheralServer.addService
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.addService(Object object)
Add a service.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| service | Object | Yes | Object describing the service | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
Structure of object.service
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| uuid | String | Yes | UUID of the Bluetooth service | |
| characteristics | Array.Object | Yes | List of characteristics |
Structure of characteristics
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| uuid | String | Yes | UUID of the characteristic | |
| properties | Object | No | Supported operations of the characteristic | |
| permission | Object | No | Permissions of the characteristic | |
| value | ArrayBuffer | No | Binary value corresponding to the characteristic | |
| descriptors | Array.Object | No | Descriptor data |
Structure of properties
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| write | Boolean | false | No | Write |
| writeNoResponse | Boolean | false | No | Write without response |
| read | Boolean | false | No | Read |
| notify | Boolean | false | No | Subscribe |
| indicate | Boolean | false | No | Acknowledgment |
Structure of permission
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| readable | Boolean | false | No | Readable |
| writeable | Boolean | false | No | Writable |
| readEncryptionRequired | Boolean | false | No | Encrypted read request |
| writeEncryptionRequired | Boolean | false | No | Encrypted write request |
Structure of descriptors
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| uuid | String | Yes | UUID of the Descriptor | |
| permission | Object | No | Permissions of the descriptor | |
| value | ArrayBuffer | No | Descriptor data |
Structure of permission
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| write | Boolean | false | No | Write |
| read | Boolean | false | No | Read |
# BLEPeripheralServer.close
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.close(Object object)
Close the current server.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# BLEPeripheralServer.offCharacteristicReadRequest
BLEPeripheralServer.offCharacteristicReadRequest()
Unlisten to the event where a connected device requests to read the characteristic value of the current peripheral device.
# BLEPeripheralServer.offCharacteristicSubscribed
BLEPeripheralServer.offCharacteristicSubscribed()
Unlisten to the characteristic subscription event.
# BLEPeripheralServer.offCharacteristicUnsubscribed
BLEPeripheralServer.offCharacteristicUnsubscribed()
Unlisten to the event where a characteristic subscription is canceled.
# BLEPeripheralServer.offCharacteristicWriteRequest
BLEPeripheralServer.offCharacteristicWriteRequest()
Unlisten to the event where a connected device requests to write the characteristic value of the current peripheral device.
# BLEPeripheralServer.onCharacteristicReadRequest
BLEPeripheralServer.onCharacteristicReadRequest(function callback)
Parameters
function callback
Callback function for the event where a connected device requests to read the characteristic value of the current peripheral device.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| serviceId | String | UUID of the service corresponding to the Bluetooth characteristic |
| characteristicId | String | UUID of the Bluetooth characteristic |
| callbackId | Number | Unique identifier, used when calling writeCharacteristicValue |
Note Repeated calls will override the previous callback.
# BLEPeripheralServer.onCharacteristicSubscribed
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.onCharacteristicSubscribed(function callback)
Listen to the characteristic subscription event, only supported on iOS.
Parameters
function callback
Callback function for the characteristic subscription event.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| serviceId | String | UUID of the service corresponding to the Bluetooth characteristic |
| characteristicId | String | UUID of the Bluetooth characteristic |
Note Repeated calls will override the previous callback.
# BLEPeripheralServer.onCharacteristicUnsubscribed
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.onCharacteristicUnsubscribed(function callback)
Listen to the event where a characteristic subscription is canceled, only supported on iOS.
Parameters
function callback
Callback function for the event where a characteristic subscription is canceled.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| serviceId | String | UUID of the service corresponding to the Bluetooth characteristic |
| characteristicId | String | UUID of the Bluetooth characteristic |
Note Repeated calls will override the previous callback.
# BLEPeripheralServer.onCharacteristicWriteRequest
Supported from Base Library 2.11.2, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.onCharacteristicWriteRequest(function callback)
Listen to the event where a connected device requests to write the characteristic value of the current peripheral device. After receiving this message, you need to immediately call writeCharacteristicValue to write back the data; otherwise, the host will not receive a response.
Parameters
function callback
Callback function for the event where a connected device requests to write the characteristic value of the current peripheral device.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| serviceId | String | UUID of the service corresponding to the Bluetooth characteristic |
| characteristicId | String | UUID of the Bluetooth characteristic |
Note Repeated calls will override the previous callback.
# BLEPeripheralServer.removeService
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.removeService(Object object)
Removes a service.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| serviceId | String | Yes | UUID of the service | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# BLEPeripheralServer.startAdvertising
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.startAdvertising(Object Object)
Starts broadcasting the locally created peripheral device.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| advertiseRequest | Object | Yes | Custom broadcast parameters | |
| powerLevel | String | medium | No | Broadcast power |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Structure of Object.advertiseRequest
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| connectable | Boolean | true | No | Whether the current device is connectable |
| deviceName | String | No | The deviceName field in the broadcast, default is empty | |
| serviceUuids | Array.String | No | List of service UUIDs to broadcast. Refer to notes when using 16/32-bit UUIDs | |
| manufacturerData | Array.Object | No | Manufacturer information for broadcast. Only supported on Android; iOS cannot customize due to system restrictions. |
Structure of manufacturerData
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| manufacturerId | String | Yes | Manufacturer ID, hexadecimal starting with 0x | |
| manufacturerSpecificData | ArrayBuffer | No | Manufacturer-specific data |
Valid values for Object.powerLevel
| Value | Description | Minimum Version |
|---|---|---|
| low | Low power | |
| medium | Medium power | |
| high | High power |
Notes
- Starting from Android 8.0.9, direct use of 16/32/128-bit UUIDs is supported.
- Below Android 8.0.9, only 128-bit UUIDs are supported. When using 16/32-bit UUIDs, padding is required (the system will automatically identify if it belongs to the pre-allocated range).
- On iOS, 16-bit UUIDs must be used directly without padding to 128 bits; otherwise, the system will still transmit as 128 bits. iOS does not currently support 32-bit UUIDs.
- iOS can only initiate one broadcast at a time, while Android supports multiple simultaneous broadcasts.
# BLEPeripheralServer.stopAdvertising
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.stopAdvertising(Object object)
Stops broadcasting.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# BLEPeripheralServer.writeCharacteristicValue
Base Library 2.11.2 and above, iOS version 2.34.1, Android version 2.34.1, requires Extension SDK
BLEPeripheralServer.writeCharacteristicValue(Object Object)
Writes binary data value to the specified characteristic and notifies the connected host that the peripheral's characteristic value has changed. This interface handles whether to send a response or notify based on subscription.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| serviceId | String | Yes | UUID of the service corresponding to the Bluetooth characteristic | |
| characteristicId | String | Yes | UUID of the Bluetooth characteristic | |
| value | ArrayBuffer | Yes | Binary value corresponding to the characteristic | |
| needNotify | Boolean | Yes | Whether to notify the host that the value has been updated | |
| callbackId | Number | No | Optional, used for handling responses | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
# Bluetooth - Beacon
# stopBeaconDiscovery
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android version 2.35.9, requires BluetoothSDK
stopBeaconDiscovery(Object object)
Stops searching for nearby Beacon devices.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| 11000 | unsupport | System or device unsupported |
| 11001 | bluetooth service unavailable | Bluetooth service unavailable |
| 11002 | location service unavailable | Location service unavailable |
| 11003 | already start | Search already started |
| 11004 | not startBeaconDiscovery | Search not yet started |
| 11005 | system error | System error |
| 11006 | invalid data | Incorrect parameters |
# startBeaconDiscovery
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android version 2.35.9, requires BluetoothSDK
startBeaconDiscovery(Object object)
Starts searching for nearby Beacon devices.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| uuids | Array. | Yes | List of UUIDs broadcast by Beacon devices | |
| ignoreBluetoothAvailable | boolean | false | No | Whether to check Bluetooth status, valid only on iOS. Starting from iOS 11, even if Bluetooth is turned off in the control panel, Beacon services can still be used. |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed regardless of success or failure) |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| 11000 | unsupport | System or device unsupported |
| 11001 | bluetooth service unavailable | Bluetooth service unavailable |
| 11002 | location service unavailable | Location service unavailable |
| 11003 | already start | Search already started |
| 11004 | not startBeaconDiscovery | Search not yet started |
| 11005 | system error | System error |
| 11006 | invalid data | Incorrect parameters |
Note
- Interface authorization failure (iOS):
- If the Host-App prohibits Mini-Programs from actively requesting permissions, an error message will be returned: unauthorized disableauthorized, indicating that the SDK is prohibited from requesting Bluetooth permissions.
# onBeaconUpdate
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android does not currently support Beacon-related interfaces
onBeaconUpdate(function callback)
Listens for Beacon device update events. Only one listener can be registered.
Parameters
function callback
Callback function for Beacon device update events.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| beacons | Array.BeaconInfo | List of all currently discovered Beacon devices |
# onBeaconServiceChange
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android does not currently support Beacon-related interfaces
onBeaconServiceChange(function callback)
Listens for changes in Beacon service status. Only one listener can be registered.
Parameters
function callback
Callback function for Beacon service status change events.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| available | boolean | Whether the service is currently available |
| discovering | boolean | Whether currently in search mode |
# offBeaconUpdate
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android does not currently support Beacon-related interfaces
Cancels listening for Beacon device update events.
# offBeaconServiceChange
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android does not currently support Beacon-related interfaces
Cancels listening for Beacon service status change events.
# getBeacons
Base Library 2.11.2 and above, iOS version 2.34.1, requires Extension SDK, Android does not currently support Beacon-related interfaces
getBeacons(Object object)
Retrieves all discovered Beacon devices.
Parameters Object object
Callback function for Beacon service status change events
Parameters
Object res
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| beacons | Array.BeaconInfo | List of Beacon devices |
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 0 | ok | Normal |
| 11000 | unsupport | System or device not supported |
| 11001 | bluetooth service unavailable | Bluetooth service unavailable |
| 11002 | location service unavailable | Location service unavailable |
| 11003 | already start | Search already started |
| 11004 | not startBeaconDiscovery | Search not yet started |
| 11005 | system error | System error |
| 11006 | invalid data | Incorrect parameters |
# BeaconInfo
Beacon Device
Properties
string uuid
UUID broadcasted by the Beacon device
number major
Primary ID of the Beacon device
number minor
Secondary ID of the Beacon device
number proximity
Enumerated value indicating device distance (iOS only)
Valid values for proximity
| Value | Description | Minimum Version |
|---|---|---|
| 0 | Signal too weak to calculate distance, or non-iOS device | |
| 1 | Very close | |
| 2 | Relatively close | |
| 3 | Far |
number accuracy
Distance to the Beacon device, in meters. On iOS, if proximity is 0, accuracy is -1.
number rssi
Signal strength of the device, in dBm
# Contacts
# addPhoneContact
Add a contact to the phone's address book.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| firstName | string | Yes | First name | |
| photoFilePath | string | No | Local file path for the profile picture | |
| nickName | string | No | Nickname | |
| lastName | string | No | Last name | |
| middleName | string | No | Middle name | |
| remark | string | No | Remark | |
| mobilePhoneNumber | string | No | Mobile phone number | |
| weChatNumber | string | No | WeChat ID | |
| addressCountry | string | No | Contact address country | |
| addressState | string | No | Contact address province | |
| addressCity | string | No | Contact address city | |
| addressStreet | string | No | Contact address street | |
| addressPostalCode | string | No | Contact address postal code | |
| organization | string | No | Company | |
| title | string | No | Job title | |
| workFaxNumber | string | No | Work fax | |
| workPhoneNumber | string | No | Work phone | |
| hostNumber | string | No | Company phone | |
| string | No | |||
| url | string | No | Website | |
| workAddressCountry | string | No | Work address country | |
| workAddressState | string | No | Work address province | |
| workAddressCity | string | No | Work address city | |
| workAddressStreet | string | No | Work address street | |
| workAddressPostalCode | string | No | Work address postal code | |
| homeFaxNumber | string | No | Home fax | |
| homePhoneNumber | string | No | Home phone | |
| homeAddressCountry | string | No | Home address country | |
| homeAddressState | string | No | Home address province | |
| homeAddressCity | string | No | Home address city | |
| homeAddressStreet | string | No | Home address street | |
| homeAddressPostalCode | string | No | Home address postal code | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# chooseContact
chooseContact(Object object)
Launch the phone's address book to select a contact.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
object.success Callback Function
Parameters
Object object
| Property | Type | Description |
|---|---|---|
| phoneNumber | string | Phone number |
| displayName | string | Contact name |
| phoneNumberList | string | All phone numbers of the selected contact (on some Android systems, only contacts can be selected, not specific phone numbers) |
# Accessibility
# checkIsOpenAccessibility
Supported from Base Library 2.12.1
checkIsOpenAccessibility(Object object)
Check whether visual accessibility features are enabled.
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
object.success Callback Function
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| open | Boolean | Returns true if VoiceOver is enabled on iOS or TalkBack is enabled on Android |
# NFC Read/Write
# getNFCAdapter
Get NFC instance
Supported from Base Library 3.2.2, Android version 2.34.1, requires Extension SDK, iOS not supported
Return Value
NFCAdapter
NFC instance
Errors
| Error Code | Error Message | Description |
|---|---|---|
| 13000 | Device does not support NFC | The device does not support Near Field Communication (NFC) functionality. |
| 13001 | System NFC switch is off | The system's NFC switch is turned off. |
| 13010 | Unknown error | An unknown NFC error occurred. |
| 13019 | User is not authorized | User has not authorized. |
| 13011 | Invalid parameter | Invalid parameter. |
| 13012 | Parse NdefMessage failed | Failed to parse parameter into NdefMessage. |
| 13021 | NFC discovery already started | NFC scanning has already started. |
| 13018 | NFC discovery has not started | Attempted to stop NFC scanning without starting it. |
| 13022 | Tech already connected | Tag is already connected. |
| 13023 | Tech has not connected | Attempted to disconnect without connecting the tag. |
| 13013 | NFC tag has not been discovered | NFC tag was not scanned. |
| 13014 | Invalid tech | Invalid tag technology. |
| 13015 | Unavailable tech | Failed to retrieve corresponding technology from the tag. |
| 13024 | Function not supported | Current tag technology does not support this function. |
| 13017 | System internal error | Related read/write operation failed. |
| 13016 | Connect fail | Connection failed. |
# IsoDep
# IsoDep.close
Disconnect
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.connect
Connect to NFC tag
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.getHistoricalBytes
Get reset information
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.getMaxTransceiveLength
Get maximum transmission length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.setTimeout
Set timeout
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
# IsoDep.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function when API call ends (executed on both success and failure) |
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic
# MifareClassic.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic.getMaxTransceiveLength
Get maximum transceive length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareClassic.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight
# MifareUltralight.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight.getMaxTransceiveLength
Get maximum transceive length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# MifareUltralight.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# Ndef
# Ndef.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# Ndef.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# Ndef.offNdefMessage
Stop listening for NDEF messages
Parameters function callback
# Ndef.onNdefMessage
Listen for NDEF messages
Parameters function callback
# Ndef.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# Ndef.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# Ndef.writeNdefMessage
Overwrite NDEF tag content
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| uris | Array | No | URI array | |
| texts | Array | No | Text array | |
| records | Array | No | Array of binary objects, requiring id, type, and payload (all of ArrayBuffer type) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcA
# NfcA.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcA.connect
Connect to NFC tag Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.getAtqa
Get ATQA information
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.getMaxTransceiveLength
Get maximum transmission length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.getSak
Get SAK information
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcA.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be transmitted | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NFCAdapter
# NFCAdapter.getIsoDep
Get an IsoDep instance, which supports ISO-DEP (ISO 14443-4) standard read/write operations.
Return Value
IsoDep
# NFCAdapter.getMifareClassic
Get a MifareClassic instance, which supports read/write operations on MIFARE Classic tags.
Return Value
MifareClassic
# NFCAdapter.getMifareUltralight
Get a MifareUltralight instance, which supports read/write operations on MIFARE Ultralight tags.
Return Value
MifareUltralight
# NFCAdapter.getNdef
Get an Ndef instance, which supports reading and writing NDEF data on NDEF-formatted NFC tags.
Return Value
Ndef
# NFCAdapter.getNfcA
Get an NfcA instance, which supports read/write operations based on the NFC-A (ISO 14443-3A) standard.
Return Value
NfcA
# NFCAdapter.getNfcB
Get an NfcB instance, which supports read/write operations based on the NFC-B (ISO 14443-3B) standard.
Return Value
NfcB
# NFCAdapter.getNfcF
Get an NfcF instance, which supports read/write operations based on the NFC-F (JIS 6319-4) standard.
Return Value
NfcF
# NFCAdapter.getNfcV
Get an NfcV instance, which supports read/write operations based on the NFC-V (ISO 15693) standard.
Return Value
NfcV
# NFCAdapter.offDiscovered
Remove the listener function for NFC Tag discovery.
Parameters
function listener
The listener function passed in onDiscovered. If this parameter is not provided, all listener functions will be removed.
# NFCAdapter.onDiscovered
Listen for NFC Tags
Parameters function listener Listener function
Parameters Object res
| Property | Type | Description |
|---|---|---|
| id | ArrayBuffer | |
| techs | Array | Tech array used to match what specific standards (e.g., NfcA instances) can handle the NFC card |
| messages | Array | Optional. NdefMessage array with message format: {id: ArrayBuffer, type: ArrayBuffer, payload: ArrayBuffer} |
# NFCAdapter.startDiscovery
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NFCAdapter.stopDiscovery
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB
# NfcB.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB.getMaxTransceiveLength
Get maximum transmission length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed whether the call succeeds or fails) |
# NfcB.transceive
Send data Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF
# NfcF.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF.getMaxTransceiveLength
Get maximum transmission length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcF.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV
# NfcV.close
Disconnect
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV.connect
Connect to NFC tag
Parameters
Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV.getMaxTransceiveLength
Get maximum transmission length
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV.isConnected
Check if connected
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV.setTimeout
Set timeout duration
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| timeout | number | Yes | Set timeout duration (ms) | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |
# NfcV.transceive
Send data
Parameters Object object
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| data | ArrayBuffer | Yes | Binary data to be passed | |
| success | function | No | Callback function for successful API call | |
| fail | function | No | Callback function for failed API call | |
| complete | function | No | Callback function for when the API call ends (executed regardless of success or failure) |