Skip to main content

Release Note

SDK library#

2.0.0 (2021-09-09)#

New Feature#

  • add mpService.showActionSheet
  • add mpService.onUnhandledRejection docs
  • add cover-view and cover-image components
  • support entryPagePath field
  • add mpService.relaunch docs
  • add NetworkStatus api docs
  • add keyframe animation API
  • add mpService.exitMiniProgram docs
  • add mpService.downloadFile docs
  • add mpService.uploadFile docs
  • add pageScrollTo and onPageScroll

Bug Fix#

  • fix: getStorageSync api
  • fix: request data, requestPayment param

Others#

  • fix: types-mp-service
  • feat: support rpx unit

Migrating from 1.3.0 to 2.0.0#

  • To use the new SDK v2.0.0, please re-upload MiniProgram with new IDE v2.4.0.
  • Install latest CLI v1.2.14 $ npm install -g @binance/mp-cli
  • Rename the .babelrc to babel.config.json
  • Make code of MiniProgram compatible:
mpService.request#

Parameter:

{  url,    body,    headers,    timeout,    method,    // added in SDK 2.0.0    // data: equals to body functionally    data,    // header: equals to headers functionally    header,    // dataType?: ‘json’ | ‘other’ , should parse response data to json    dataType}

Response:

// SDK 1.3.0{  ok,  json,  text,  status,  headers,  statusText,  url,  data,}
// SDK 2.0.0{  data,  statusCode,  header,}

Compatible code:

const response = await mpService.request({ url, data, header, headers, timeout, method, dataType })if (response.json) {  const json = await response.json()  const text = await response.text()  const ok = response.ok  const status = response.status  const headers = response.headers  const statusText = response.statusText} else {  // if parameter dataType is ‘json’ data is in json format, or data is text.  const data = response.data  const ok = statusCode === 200  const headers = response.header  const status = response.statusCode  const statusText = response.statusCode.toString()}
mpService.requestPayment#

Parameter

{  prepayId, // deprecated in SDK 2.0.0  // added in SDK 2.0.0  certSn,  nonceStr,  package: "prepay_id=....",  merchantId,  paySign, // compute rule  timeStamp}

Compatible code:

const result = await mpService.requestPayment({  prepayId,  certSn,  nonceStr,  package: `prepay_id=${prepayId}`,  merchantId,  paySign,  timeStamp,})
mpService.getStorageSync#

Behaviors:

mpService.setStorage({ key: 'key', data: 'value' })mpService.getStorageSync('key') // SDK 1.3.0 response: { data: "value" }mpService.getStorageSync('key') // SDK 2.0.0 response: "value"

Compatible code:

mpService.setStorage({ key: 'key', data: 'value' })const response = bn.getStorageSync('key') // response: "value" or { data: "value" }const data = response.data || response

SDK 1.3.0#

Release date: 2021-08-19

Changelogs:

  • New APIs:

    • on/off-show/hide/off-* api
    • navigateTo now return EventChannel
    • webview postMessage support
    • hideHomeButton
    • upgrade payment api
  • New Props:

    • ScrollView: add support fastDeceleration and enhanced props (iOS only)
  • Fixed issues

    • fix: placeholder not show when the input is controlled
    • fix: margin styling issue for input / textarea component
    • fix: tap not trigger when touchmove
  • Supported DevTools

    • IDE: 2.3.0
    • CLI: 1.2.2
  • Supported Binance app versions

    • iOS: 2.34.*
    • Android: 2.34.*

SDK 1.2.0#

Release date: 2021-07-29

Changelogs:

  • Synchronous Plugins

  • Plugins with suffix "Sync" can be called synchronously. Implemented synchronous plugins:

    • getStorageSync
    • setStorageSync
    • cleanStorageSync
    • getStorageInfoSync
    • removeStorageSync
    • getSystemInfoSync
  • Scene Value

    • The scene value is used to describe the user's path to the open the mini program. Now developers can get the scene value from onLaunch or onShow callback.
  • Fixed issues

    • fixed native Input related issues
    • ViewPort and SafeArea issue for custom navigation bar and tabbar
    • NavigationBar title issue for WebView Component
  • Supported DevTools

    • IDE: 2.2.0
    • CLI: 1.2.0
  • Supported Binance app versions

    • iOS: 2.33.*
    • Android: 2.33.*

Compatibility with Older Versions#

New Mini Program features are constantly being released, but are not supported for older versions of the Binance app. Therefore, the compatibility should be addressed when using these new features.

Developers can use the following methods to ensure compatibility with older versions:

1. Version Comparison#

Versions of the Binance app and Mini Program base library are expressed in the format of Major.Minor.Patch (major version number.minor version number.patch version number).

In the documentation, the minimum sdk library versions are specified for the features described in component, API, and other pages.

In a Mini Program, developers can call bn.getSystemInfo or bn.getSystemInfoSync to get the version of the sdk library run by the Mini Program. The version comparison method is used to run a lower version for compatibility purposes.

Note: Do not compare versions by directly comparing the strings.

See the sample code below:

import { gt } from 'semver'const version = bn.getSystemInfoSync().SDKVersion
if (gt(version, '1.2.0')) {  bn.getStorageSync('my-data')} else {  // If you want users to experience the Mini Program in the latest app, you can display a prompt like this:  bn.showModal({    title: 'Prompt',    content:      'Your cannot use this feature due to low Binance version. Please upgrade to the latest Binance version and try again.',  })}

2. bn.canIUse#

In addition to a direct judgment by the version number, you can also use bn.canIUse to determine if a feature can be used directly under the current base library version.

bn.showModal({  success: function (res) {    if (bn.canIUse('showModal')) {      console.log(res.cancel)    }  },})