# Others
# base64ToTempFilePath
base64ToTempFilePath(Object object)
Saves the base64 data of an image to the local sandbox and returns the local cache path.
| Property | Type | Default Value | Required | Description |
|---|---|---|---|---|
| x | number | 0 | No | The x-coordinate of the upper-left corner of the area to be cropped |
| y | number | 0 | No | The y-coordinate of the upper-left corner of the area to be cropped |
| width | number | canvas width - x | No | The width of the area to be cropped |
| height | number | canvas height - y | No | The height of the area to be cropped |
| destWidth | number | width x screen pixel density | No | The width of the output image |
| destHeight | number | height x screen pixel density | No | The height of the output image |
| base64Data | string | Yes | The base64-encoded string of the image | |
| 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 |
|---|---|---|
| tempFilePath | string | The local address of the image |
# onCustomEvent
onCustomEvent(callback)
Listens for the onCustomEvent event.
Sample Code
const callback = (res) => {
console.log(res) // Get parameters passed from native
}
ft.onCustomEvent(callback)
# offCustomEvent
offCustomEvent(callback)
Cancels listening for the onCustomEvent event.
Sample Code
const callback = (res) => {}
ft.onCustomEvent(callback)
ft.offCustomEvent(callback)
# addCustomEventListener
addCustomEventListener(eventName, callback)
This event is a wrapper based on onCustomEvent, effectively reducing template code within onCustomEvent.
Note When using this event, for it to trigger normally, the data body must include a name field when the SDK calls the event, indicating which eventName is being triggered.
For example:
{
name: 'someMethod', // Required field
data: {
a: 'data-1',
b: 'data-2',
c: 1001
},
errMsg: 'some error msg'
}
The entire data will be passed through to the callback.
Sample Code
const callback = (res) => {
console.log(res) // Get parameters passed from native
}
ft.addCustomEventListener('someMethod', callback)
# removeCustomEventListener
removeCustomEventListener(eventName, callback)
Removes the listener added by addCustomEventListener.
Sample Code
const callback = (res) => {
console.log(res) // Get parameters passed from native
}
ft.removeCustomEventListener('someMethod', callback)