Mini App Document Mini App Document
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • API overview
  • Basics
    • env
    • base64ToArrayBuffer
    • arrayBufferToBase64
    • System
      • getSystemInfoSync
      • getSystemInfoAsync
      • getSystemInfo
    • Update
      • getUpdateManager
    • MiniApps
      • getLaunchOptionsSync
      • getEnterOptionsSync
      • onPageNotFound
      • onError
      • onAppShow
      • onAppHide
      • offPageNotFound
      • offError
      • offAppShow
      • offAppHide
    • Debugging
      • setEnableDebug
    • Version information
      • getAccountInfoSync
  • Routing
  • Jump
  • Forwarding
  • Interface
  • Network
  • Data caching
  • Media
  • Map
  • Location
  • File
  • Device
  • Canvas
  • FXML
  • Customize the menu
  • Other
  • API
2022-08-09
Directory

Basics

# env

ft.env

environment variable

Properties

string USER_DATA_PATH

User directory path in the file system (local path)

# base64ToArrayBuffer

ArrayBuffer ft.base64ToArrayBuffer(string base64)

Converts the Base64 string to an ArrayBuffer object

Parameters

string base64

The Base64 string to be converted to an ArrayBuffer object

Return Value

ArrayBuffer

ArrayBuffer object

Sample code

# arrayBufferToBase64

string ft.arrayBufferToBase64(ArrayBuffer arrayBuffer)

Convert the ArrayBuffer object to a Base64 string

Parameters

ArrayBuffer arrayBuffer

The ArrayBuffer object to convert to a Base64 string

Return Value

string

Base64 string

Sample Code

# System

# getSystemInfoSync

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

getSystemInfoSync(Object object)

getSystemInfoSync synchronization version.

# getSystemInfoAsync

ft.getSystemInfoAsync(Object object)

Asynchronously obtains system information

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function

Parameters

Object res

Properties Type Description Minimum version
brand string The device brand 1.5.0
model string Device model. The new model will show unknown for a while and will be adapted as soon as possible.
pixelRatio number The device pixel ratio is
screenWidth number Screen width, in px 1.1.0
screenHeight number Screen height, in px 1.1.0
windowWidth number You can use window width, in units px
windowHeight number Window heights can be used in px
statusBarHeight number The height of the status bar, in px 1.9.0
language string The language for app settings
version string Version number
system string Operating system and version
platform string Client Platform
fontSizeSetting number The user font size (in px) 1.5.0
SDKVersion string Client Base Library Version 1.1.0
benchmarkLevel number Device performance level (Android only). Values are: -2 or 0 (the device cannot run mini-games), -1 (performance unknown), >=1 (device performance value, the higher the value, the better the device performance, currently up to less than 50) 1.8.0
albumAuthorized boolean The switch that allows the use of albums (effective only for iOS) 2.6.0
cameraAuthorized boolean The switch that allows the use of the camera 2.6.0
locationAuthorized boolean Switches that allow positioning are 2.6.0
microphoneAuthorized boolean The switch that allows the use of the microphone 2.6.0
notificationAuthorized boolean The switch that allows notifications 2.6.0
notificationAlertAuthorized boolean Allow notification of switches with reminders (iOS only) 2.6.0
notificationBadgeAuthorized boolean Allow notification of tagged switches (iOS only) 2.6.0
notificationSoundAuthorized boolean Allows notification of switches with sound (iOS only) 2.6.0
bluetoothEnabled boolean The system switch for Bluetooth 2.6.0
locationEnabled boolean The system switch for geographic location 2.6.0
wifiEnabled boolean The system switch for Wi-Fi is 2.6.0
safeArea Object The safe area under the portrait screen is 2.7.0
locationReducedAccuracy boolean 'true' for fuzzy positioning, 'false' for precise positioning, and only iOS supports
theme string The current theme of the system can only be obtained when the value is 'light' or 'dark', which can only be obtained when the global configuration is ''darkmode':true', otherwise it is undefined (does not support mini games) 2.11.0
host Object The host environment in which the current MiniApp is running 2.12.3
enableDebug boolean Whether debugging is turned on. Debugging can be opened from the menu in the upper-right corner or ft.setEnableDebug. 2.15.0
bundleId string The bundleId of the host app 2.15.0
deviceOrientation string Device Orientation

Structure of safeArea

Properties Type Description
left number The upper-left abscissa of the safe zone is
right number The abscissa coordinate of the lower-right corner of the safe zone
top number The upper-left ordinate of the safe zone
bottom number The lower-right ordinate of the safe zone
width number The width of the security zone,
height number The height of the security zone,

Valid value of theme

The value Description Minimum version
dark Dark theme
light Light theme

host structure

Properties Type Description
appId string The appId for the host app

deviceOrientation 的合法值

The value Description Minimum version
portrait Portrait screen
landscape Landscape

Sample Code

Preview the effect in the developer tools

# getSystemInfo

Base Library 1.3.9 is supported, iOS version 2.1.23, Android version 2.1.38

getSystemInfo(Object object)

Get system information.

Parameters

Object object

Properties Type The default value is Required Description
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

object.success callback function Argument

Object res

Properties Type Description
SDKVersion string The MiniApp base library version number
runtimeSDKVersion string The MiniApp SDK version number
brand string The device brand
model string Device model
pixelRatio number The device pixel ratio is
screenWidth number Screen width, in px
screenHeight number Screen height, in px
windowWidth number You can use window width, in units px
windowHeight number Window heights can be used in
statusBarHeight number The height of the status bar, in px
language string The host app sets the language
version string The version number of the host app is
bundleId string The bundleId of the host app
system string Operating system and version
platform string Client Platform
deviceId string Device Identity

Sample Code

# Update

# getUpdateManager

Base Library 1.5.30 is supported, iOS version 2.5.6, Android version 2.8.76

Gets the globally unique version update manager for managing MiniApp updates. Returns the UpdateManager

UpdateManager method

UpdateManager.applyUpdate() forces the MiniApp to restart and use the new version. The call is made after the new version of the Mini App is downloaded (that is, the onUpdateReady callback is received).

UpdateManager.onCheckForUpdate(function callback) listens for events that request to the background to check for update results. The SDK automatically checks for updates when the Mini App starts cold, and does not need to be actively triggered by the developer.

UpdateManager.onUpdateReady(function callback) Listens for version update events in the MiniApp. The client actively triggers the download (no developer is required to trigger), and after the download is successful, the callback UpdateManager.onUpdateFailed(function callback) listens for the Mini App update failure event. There is a new version of the Mini App, the client actively triggers the download (no developer is required to trigger), and the download fails (may be due to network reasons, etc.).

Sample Code

# MiniApps

# getLaunchOptionsSync

Object ft.getLaunchOptionsSync() Gets the parameters when the MiniApp starts. Consistent with the callback parameters of 'App.onLaunch'.

Return Value

Object

Startup parameters

Properties Type Description
path string The path to the startup MiniApp (code package path)
scene number The scene value of the startup MiniApp
query Object The query parameter
shareTicket string ShareTicket, see Get more forwarding information for details
referrerInfo Object Source Information

Structure of referrerInfo

Properties Type Description
appId string The appId of the source Mini App, Official Account, or App
extraData Object The data transmitted by the source Mini App supports

Structure of forwardMaterials

Properties Type Description
type string The mimetype type of the file
name string The file name is
path string The file path (or url in the case of webview)
size number File size

Returns a valid referrerInfo scenario

Scene value Scene appId means
1020 List of relevant Mini Apps on the Profile Page Source public number
1035 Official account custom menu Source public number
1036 App Share Message Card Source App
1037 The MiniApp opens the MiniApp Source MiniApp
1038 Returns from another MiniApp Source MiniApp
1043 Official account template message Source public number
1069 Mobile apps Source App

# getEnterOptionsSync

Object ft.getEnterOptionsSync()

Get the parameters when the Mini App starts. If it is currently a cold start, the return value is the same as the callback parameter of 'App.onLaunch'; If it is currently a hot launch, the return value is the same as 'App.onShow'.

Return Value

Object

Startup parameters

Properties Type Description
path string The path to the startup MiniApp (code package path)
scene number The scene value of the startup MiniApp
query Object The query parameter
shareTicket string ShareTicket, see Get more forwarding information for details
referrerInfo Object Source Information

Structure of referrerInfo

Properties Type Description
appId string The appId of the source Mini App, Official Account, or App
extraData Object The data transmitted by the source Mini App supports

Returns a valid referrerInfo scenario

Scene value Scene appId means
1020 List of relevant Mini Apps on the Profile Page Source public number
1035 Official account custom menu Source public number
1036 App Share Message Card Source App
1037 The MiniApp opens the MiniApp Source MiniApp
1038 Returns from another MiniApp Source MiniApp
1043 Official account template message Source public number

NOTE

Some versions return 'undefined' when there is no 'referrerInfo', and it is recommended to use 'options.referrerInfo && options.referrerInfo.appId' to judge.

# onPageNotFound

ft.onPageNotFound(function callback)

There are no events for the page that the listener Mini App is going to open. The event coincides with the callback timing of 'App.onPageNotFound'.

Parameters

function callback

The page to be opened by the MiniApp does not have an event callback function

Parameters

Object res

Properties Type Description
path string The path to the page (code package path)
query Object Opens the query parameter
isEntryPage boolean Whether the first page launched this time (for example, from the sharing and other entrances, the first page is the sharing page configured by the developer)

NOTE

  • Developers can do page redirection in the callback, but must be handled in the callback with asynchronous processing (e.g. 'setTimeout' asynchronous execution) not valid.
  • If the developer does not call the ft.onPageNotFound binding listener, nor does it declare 'App.onPageNotFound', when the jump page does not exist, it will be pushed into the native page does not exist.
  • If the callback redirects to another page that does not exist, it will be pushed to the native page without a hint page and will not be called back a second time.

# onError

ft.onError(function callback)

Listen for MiniApp error events. Such as script errors or API calls to report errors. The event coincides with the callback timing and parameters of 'App.onError'.

Parameters

function callback

A callback function for MiniApp error events

Parameters

string error

Error message, including the stack

# onAppShow

ft.onAppShow(function callback)

Listen for MiniApps to cut front-end events. The event matches the callback parameter for 'App.onShow'.

Parameters

function callback

The MiniApp cuts the callback function for the foreground event

Parameters

Object res

Properties Type Description
path string The path (code package path) where the MiniApp cuts to the foreground
scene number The scene value of the MiniApp cuts to the foreground
query Object The MiniApp cuts the foreground query parameter
shareTicket string ShareTicket, see Get more forwarding information for details
referrerInfo Object Source Information. Returns when entering a Mini App from another Mini App, Official Account, or App. Otherwise returns '{}'. (See note below)
forwardMaterials Array. < object > opens an array of file information that can only be carried with

Structure of referrerInfo

Properties Type Description
appId string The appId of the source Mini App, Official Account, or App
extraData Object The data transmitted by the source Mini App supports

Structure of forwardMaterials

Properties Type Description
type string The mimetype type of the file
name string The file name is
path string The file path (or url in the case of webview)
size number File size

Returns a valid referrerInfo scenario

Scene value Scene appId means
1020 List of relevant Mini Apps on the Profile Page Source public number
1035 Official account custom menu Source public number
1036 App Share Message Card Source App
1037 The MiniApp opens the MiniApp Source MiniApp
1038 Returns from another MiniApp Source MiniApp
1043 Official account template message Source public number

NOTE

Some versions return 'undefined' when there is no 'referrerInfo', and it is recommended to use 'options.referrerInfo && options.referrerInfo.appId' to judge.

# onAppHide

ft.onAppHide(function callback)

Listen for MiniApps to cut background events. The event coincides with the callback timing of 'App.onHide'.

Parameters

function callback

A callback function for a Mini App to cut background events

# offPageNotFound

ft.offPageNotFound(function callback)

Cancel the monitoring of the page that the MiniApp is going to open does not have an event

Parameters

function callback

The page to be opened by the MiniApp does not have an event callback function

# offError

ft.offError(function callback)

Cancels listening for MiniApp error events.

Parameters

function callback

A callback function for MiniApp error events

# offAppShow

ft.offAppShow(function callback)

Cancel the listening MiniApp to cut the foreground event

Parameters

function callback

The MiniApp cuts the callback function for the foreground event

# offAppHide

ft.offAppHide(function callback)

Cancels the listening MiniApp to cut background events

Parameters

function callback

A callback function for a Mini App to cut background events

# Debugging

# setEnableDebug

ft.setEnableDebug(Object object)

Sets whether to turn on the debug switch. This switch also works for the general version.

Parameters

Object object

Properties Type The default value is Required Description
enableDebug boolean Yes Whether to open the Debug
success function No The interface calls the callback function successfully
fail function No The callback function that failed the interface callback function
complete function No The callback function at the end of the interface call (the call succeeds or fails)

Sample Code

Tips

  • Another way to open debugging in the production version is to open debugging in the development or test version, and then cut to the official version to see vConsole.

# Version information

# getAccountInfoSync

Gets the current MiniApp information

Return Value

Object object

Properties Type The default value is Required Description
miniProgram Object Yes Mini App account information

Object miniProgram

Properties Type Description
appId string The MiniApp appId
envVersion string Mini App Version develop:Development Trial:Trial Release:Official Review:Review Version
Last update: 2022/08/16, 21:24:25
API overview
Routing

← API overview Routing→

Copyright © 2020-2024 Neuxnet
  • Follow System
  • Light Mode
  • Dark Mode
  • Reading Mode