Appearance
Basics 
env 
ft.env
Environmental variables
attribute
string USER_DATA_PATH
User directory path in file system (Local path)
base64ToArrayBuffer 
ArrayBuffer ft.base64ToArrayBuffer(string base64)
will Base64 String ArrayBuffer object
parameter
string base64
To translate into ArrayBuffer Object Base64 Character string
返回值
ArrayBuffer
ArrayBuffer object
sample code
javascript
const base64 = 'CxYh'
const arrayBuffer = ft.base64ToArrayBuffer(base64)arrayBufferToBase64 
string ft.arrayBufferToBase64(ArrayBuffer arrayBuffer)
will ArrayBuffer Object conversion Base64 Character string
parameter
ArrayBuffer arrayBuffer
To convert Base64 String ArrayBuffer object
Return value
string
Base64 Character string
sample code
javascript
const arrayBuffer = new Uint8Array([11, 22, 33])
const base64 = ft.arrayBufferToBase64(arrayBuffer)base64ToTempFilePath 
Basic library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38
base64ToTempFilePath(Object object)
Save the base64 data of the image to the local sandbox and return the local cache path.
| Property | Type | The default value is | Required | Description | 
|---|---|---|---|---|
| x | number | 0 | No | The upper-left abscissa of the area to be cropped is | 
| y | number | 0 | No | The upper-left ordinate of the area to be cropped is | 
| 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 is | 
| destWidth | number | width x screen pixel density | No | The width of the output picture is | 
| destHeight | number | height x screen pixel density | No | The height of the output picture is | 
| base64Data | string | Yes | The image is converted into a base64 type string | |
| success | function | No | The interface calls the callback function | |
| fail | function | No | Interface call failed callback function | |
| complete | function | No | The callback function at the end of the interface call (the call succeeds or fails to execute | 
object.success callback function
Parameter
Object res
| Property | Type | Description | 
|---|---|---|
| tempFilePath | string | The local address of the picture | 
fileToBase64 
fileToBase64(Object object)
will file converted to Base64 Character string
Parameter
Object res
| Property | Type | Description | 
|---|---|---|
| url | string | File address | 
Return value
string
Base64 String
System 
getSystemInfoSync 
Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38
getSystemInfoSync()
The synchronous version of ft.getSystemInfo
getSystemInfoAsync 
ft.getSystemInfoAsync(Object object)
Get system information asynchronously. Need some WeChat client version support, in the unsupported client, will use synchronization to return.
parameter
Object object
| attribute | type | Default values | Required | Introductions | 
|---|---|---|---|---|
| success | function | no | Interface calls the successful callback function | |
| fail | function | no | Interface calls failed callback functions | |
| complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) | 
object.success callback
parameter
Object res
| attribute | type | Introductions | Minimum version | 
|---|---|---|---|
| brand | string | Equipment brand | 1.5.0 | 
| model | string | Device model. New models will show unknown for a while, WeChat will adapt as soon as possible. | |
| pixelRatio | number | Device pixel ratio | |
| screenWidth | number | Screen width, in px | 1.1.0 | 
| screenHeight | number | Screen height, in px | 1.1.0 | 
| windowWidth | number | Available window width, unit px | |
| windowHeight | number | Available window height, in px | |
| statusBarHeight | number | Height of status bar in px | 1.9.0 | 
| language | string | Language of WeChat settings | |
| version | string | WeChat version number | |
| system | string | Operating System and Version | |
| platform | string | Client platform | |
| fontSizeSetting | number | User font size in px. WeChat ClientI - Settings - Universal - Font SizeThe settings in | 1.5.0 | 
| SDKVersion | string | Client base library version | 1.1.0 | 
| benchmarkLevel | number | Equipment Performance Level (only Android)。 Values are: -2 or 0 (the device cannot run games), -1 (performance unknown),>= 1 (Device Performance Value, higher the value, better device performance, currently up to less than 50) | 1.8.0 | 
| albumAuthorized | boolean | Allow WeChat to use the Photo Album switch (only iOS Effective) | 2.6.0 | 
| cameraAuthorized | boolean | Switch that allows WeChat to use the camera | 2.6.0 | 
| locationAuthorized | boolean | Allow WeChat to use location switch | 2.6.0 | 
| microphoneAuthorized | boolean | Switch allowing WeChat to use microphone | 2.6.0 | 
| notificationAuthorized | boolean | Switch that allows WeChat notifications | 2.6.0 | 
| notificationAlertAuthorized | boolean | Allow WeChat to notify switches with reminders (only iOS Effective) | 2.6.0 | 
| notificationBadgeAuthorized | boolean | Allow WeChat notifications with marked switches (only iOS Effective) | 2.6.0 | 
| notificationSoundAuthorized | boolean | Allow WeChat to notify switches with sound (only iOS Effective) | 2.6.0 | 
| bluetoothEnabled | boolean | Bluetooth System Switch | 2.6.0 | 
| locationEnabled | boolean | Geographic Location System Switch | 2.6.0 | 
| wifiEnabled | boolean | Wi-Fi System switch | 2.6.0 | 
| safeArea | Object | A safe area in the positive direction of the vertical screen | 2.7.0 | 
| locationReducedAccuracy | boolean | true Represents fuzzy positioning,false For precise positioning, only iOS Support | |
| theme | string | System current theme, with a value oflightordark, global configuration'darkmode': trueCan be obtained when otherwise undefined (Small games not supported) | 2.11.0 | 
| enableDebug | boolean | Whether debugging is turned on. Available from the top right menu or ft.setEnableDebug Turn on debugging. | 2.15.0 | 
| bundleId | string | The bundleId of the host app | 2.15.0 | 
| deviceOrientation | string | Equipment direction | 
safeArea Structure
| attribute | type | Introductions | 
|---|---|---|
| left | number | Upper left abscissa of security area | 
| right | number | Security area lower right abscissa | 
| top | number | Top-left ordinate of security area | 
| bottom | number | Lower right ordinate of security area | 
| width | number | Width of security area, unit logical pixels | 
| height | number | Height of Safe Area, Unit Logical Pixels | 
theme Legal value
| value | Introductions | Minimum version | 
|---|---|---|
| dark | Dark theme | |
| light | Light color theme | 
host Structure
| attribute | type | Introductions | 
|---|---|---|
| appId | string | host app Corresponding appId | 
deviceOrientation Legal value
| value | Introductions | Minimum version | 
|---|---|---|
| portrait | Vertical screen | |
| landscape | Horizontal screen | 
sample code
Preview with Developer Tool
js
ft.getSystemInfoAsync({
  success (res) {
    console.log(res.model)
    console.log(res.pixelRatio)
    console.log(res.windowWidth)
    console.log(res.windowHeight)
    console.log(res.language)
    console.log(res.version)
    console.log(res.platform)
  }
})getSystemInfo 
Supported since base library 1.3.9, iOS version 2.1.23, Android version 2.1.38
getSystemInfo(Object object)
Gets system information.
Parameters
Object object
| Property | Type | Default | Required | Description | 
|---|---|---|---|---|
| success | function | No | The callback function for a successful API call | |
| fail | function | No | The callback function for a failed API call | |
| complete | function | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) | 
object.success callback function  Parameters
Object res
| Property | Type | Description | 
|---|---|---|
| SDKVersion | string | Base library version for the WeChat app | 
| runtimeSDKVersion | string | mini program SDK version number | 
| brand | string | Device brand | 
| model | string | Device model | 
| pixelRatio | number | Device's pixel ratio | 
| screenWidth | number | Screen width in px | 
| screenHeight | number | Screen height in px | 
| windowWidth | number | Available window width in px | 
| windowHeight | number | Available window height in px | 
| statusBarHeight | number | Status bar height in px | 
| language | string | Language set in WeChat | 
| version | string | WeChat version | 
| bundleId | string | The bundleId of the host application | 
| system | string | Operating system and version | 
| platform | string | Client platform | 
| inFinChat | boolean | Is it in the finchat mini program environment | 
| deviceId | string | Equipment identification | 
Sample Code
javascript
 ft.getSystemInfo({
  success(res) {
    console.log(res.model)
    console.log(res.pixelRatio)
    console.log(res.windowWidth)
    console.log(res.windowHeight)
    console.log(res.language)
    console.log(res.version)
    console.log(res.platform)
  }
})Updates 
getUpdateManager 
Supported since base library 1.5.30, iOS version 2.5.6, Android version 2.8.76
ObtainGlobally uniqueThe version update manager for managing Mini Program updates. Update on the Mini Program mechanism, you can seeOperation mechanismDocumentation.
UpdateManager method
UpdateManager.applyUpdate() Force the Mini Program to restart and use the new version. After the new version of the Mini Program has been downloaded (i.e. received onUpdateReady Callback) call.
UpdateManager.onCheckForUpdate(function callback) Monitor the WeChat background request to check the update results event. WeChat automatically checks updates when the Mini Program is cold started, without the developer taking the initiative to trigger.
UpdateManager.onUpdateReady(function callback) Listening Mini Program has a version update event. Active client trigger download (no developer trigger), download success callback
UpdateManager.onUpdateFailed(function callback) Listen for Mini Programs to update failed events. Mini Program has a new version, the client active trigger download (without developer trigger), download failure (may be network reasons, etc.) after the callback
sample code
javascript
const updateManager = ft.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
  // Callback after requesting new version information
  console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function () {
  ft.showModal({
    title: 'Update tip ',
    content: 'The new version is ready, reboot the app? ' ',
    success: function (res) {
      if (res.confirm) {
        // The new version has been downloaded and calls applyUpdate Apply a new version and restart
        updateManager.applyUpdate()
      }
    }
  })
})
updateManager.onUpdateFailed(function () {
  // New version download failed
})Mini Program 
getLaunchOptionsSync 
Object ft.getLaunchOptionsSync() Gets the parameters for startup of the Mini Programs. and App.onLaunch The callback parameters of
Return value
Object
Starting parameter
| attribute | type | Introductions | 
|---|---|---|
| path | string | Path to start Mini Programs (Code packet path) | 
| query | Object | Start the Mini Program query parameter |
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the Mini Program. Otherwise return {}。(See below for attention) |
referrerInfo Structure
| attribute | type | Introductions | 
|---|---|---|
| appId | string | The appId of Mini Program | 
| extraData | Object | Source Mini Program passed data | 
getEnterOptionsSync 
Object ft.getEnterOptionsSync()
Gets the parameters of this Mini Program when it starts. If the current is a cold start, the return value is identical to the App.onLaunch Consistent with the callback parametersIf this is a hot start, the return value is identical to the App.onShow Consistent
Return value
Object
Starting parameter
| attribute | type | Introductions | 
|---|---|---|
| path | string | Path to start Mini Programs (Code packet path) | 
| query | Object | Start the Mini Program query parameter |
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the Mini Program. Otherwise return {}。(See below for attention) |
referrerInfo Structure
| attribute | type | Introductions | 
|---|---|---|
| appId | string | The appId of Mini Program | 
| extraData | Object | Source Mini Program passed data | 
onPageNotFound 
ft.onPageNotFound(function callback)
There are no events on the page that the listening Mini Program wants to open. This event is related to App.onPageNotFound The timing of the pullback was consistent
parameter
function callback
The callback function for the page that the Mini Program opens does not exist
parameter
Object res
| attribute | type | Introductions | 
|---|---|---|
| path | string | No path to the page (Code packet path) | 
| query | Object | Open a page that does not exist query parameter | 
| isEntryPage | boolean | Is the first page of this launch (for example, from the Share entrance, the first is the developer configuration share page) | 
Be careful
- Developers can do page redirection in callbacks, but only in callbacksynchronizationProcessing, asynchronous processing such as 
setTimeoutAsynchronous execution) is invalid. - If the developer does not call ft.onPageNotFound Binding listening, no declaration 
App.onPageNotFound, When the jump page does not exist, will push the WeChat client native page there is no prompt page. - If the callback is redirected to another page that does not exist, the original page of WeChat client will be pushed into the page that is not there and there will be no second callback.
 
onError 
ft.onError(function callback)
Listens for Mini Program error events. Such as a script error or API Call error, etc. This event is related to App.onError The callback timing of the.
parameter
function callback
Callback function for Mini Program error event
parameter
string error
Error message, including stack
onAppShow 
ft.onAppShow(function callback)
Listen to the Mini Program cut foreground events. This event is related to App.onShow The callback parameters of
parameter
function callback
Callback Function for Mini Programs to Cut Foreground Events
parameter
Object res
| attribute | type | Introductions | 
|---|---|---|
| path | string | Mini Programs cut the foreground path (Code packet path) | 
| query | Object | Mini Program cut the front desk query parameter | 
| referrerInfo | Object | Source information. From another little program, Official Account message template or App Returns when entering the Mini Program. Otherwise return {}。(See below for attention) | 
referrerInfo Structure
| attribute | type | Introductions | 
|---|---|---|
| appId | string | The appId of Mini Program | 
| extraData | Object | Source Mini Program passed data | 
Be careful
Partial Version NoreferrerInfoWill return when undefinedRecommended for use options.referrerInfo && options.referrerInfo.appId To judge.
onAppHide 
ft.onAppHide(function callback)
Listen to the Mini Program cut background events. This event is related to App.onHide The timing of the pullback was consistent.
parameter
function callback
Callback Function for Background Events
offPageNotFound 
ft.offPageNotFound(function callback)
The page to be opened by the unlisten Mini Program does not have an event
parameter
function callback
The callback function for the page that the Mini Program opens does not exist
offError 
ft.offError(function callback)
Cancels listening for Mini Program error events
parameter
function callback
Callback function for Mini Program error event
offAppShow 
ft.offAppShow(function callback)
Cancel the monitor Mini Program to cut the foreground event
parameter
function callback
Callback Function for Mini Programs to Cut Foreground Events
offAppHide 
ft.offAppHide(function callback)
Cancel listening Mini Program to cut background event
parameter
function callback
Callback Function for Background Events
onThemeChange 
ft.onThemeChange(function callback)
Listen for system topic change events
parameter
function callback
Callback function for the system topic change event
onUnhandledRejection 
ft.onUnhandledRejection(function callback)
Listen for unprocessed Promise rejection events
parameter
function callback
Callback function for an unhandled Promise rejection event
offUnhandledRejection 
ft.offUnhandledRejection(function callback)
Cancel listening for unprocessed Promise rejection events
parameter
function callback
onUnhandledRejection Incoming callback function. If this argument is not passed, all listening functions are removed.
offThemeChange 
ft.offThemeChange(function callback)
Cancels listening for system topic change events
parameter
function callback
onThemeChange The callback function passed in. If this parameter is not passed, all listener functions are removed.
debugging 
setEnableDebug 
ft.setEnableDebug(Object object)
Sets whether the debug switch is turned on. This switch also works for the official version
parameter
Object object
| attribute | type | Default values | Required | Introductions | 
|---|---|---|---|---|
| enableDebug | boolean | yes | Turn on debugging | |
| success | function | no | Interface calls the successful callback function | |
| fail | function | no | Interface calls failed callback functions | |
| complete | function | no | Callback function at the end of an interface call (both successful and unsuccessful calls are executed) | 
sample code
javascript
// Turn on debugging
ft.setEnableDebug({
  enableDebug: true
})
// Close debugging
ft.setEnableDebug({
  enableDebug: false
})Tips
- In the official version to open debugging there is a way that is first in the development version or the experience version of the open debugging, and then cut to the formal version can see vConsole.
 
console 
Prints logs to the debugging console. The "console" is a global object and can be accessed directly. In the WeChat app, logs are output to vConsole.
console.debug()
Prints the "debug" log to the debugging panel.
console.error()
Prints the "error" log to the debugging panel.
console.group()
Creates a new group in the debugging panel.
console.groupEnd()
Ends a group created by console.group.
console.info()
Prints the "info" log to the debugging panel.
console.log()
Prints the "log" log to the debugging panel.
console.warn()
Prints the "warn" log to the debugging panel.
LogManager 
Log manager instance
LogManager.debug()
write debug journal
LogManager.info()
write info journal
LogManager.log()
write log journal
LogManager.warn()
write warn journal
RealtimeLogManager 
Real - time log manager instance
RealtimeLogManager.info()
write info Logging is not supported in plugins
RealtimeLogManager.warn()
write warn Logging is not supported in plugins
RealtimeLogManager.error()
write error Logging is not supported in plugins
RealtimeLogManager.setFilterMsg(string msg)
Set filter keywords, temporarily do not support the use of
RealtimeLogManager.addFilterMsg(string msg)
Add filter keywords, temporarily not supported in plugin use
Account information 
getAccountInfoSync 
Gets the current account information. Online Mini Program version number is only available in the official version of the Mini Program, development version and experience version can not be obtained
Return value
Object object
| attribute | type | Default values | Required | Introductions | 
|---|---|---|---|---|
| miniProgram | Object | yes | Mini Program account information | 
Object miniProgram
| attribute | type | Introductions | 
|---|---|---|
| appId | string | Mini Program appId | 
| envVersion | string | Mini Program version |