MiniProgram SDK API

Last updated:2021-12-15
Expand all
MiniProgram SDK API
  • new JMLink(config)

  • API description: used to bind backend-configured parameters for redirecting to the app.

  • Parameter description: config is the initialization parameter.

  • Call example:

new JMLink({ wx, jmlink: 'short link', // Short link address plhparams:{ a:"zdy", // Dynamic parameter }, callback: ({link}) => { this.setData({ parameter: link, }) } })
           new JMLink({
 wx,
 jmlink: 'short link', // Short link address
 plhparams:{
 a:"zdy", // Dynamic parameter
 },
 callback: ({link}) => {
 this.setData({
 parameter: link,
 })
 }
 })

        
This code block is shown in the floating window

Initialization Parameter config

config.wx (required)

  • wx object
  • Type: String
  • Description: assigned by the backend, short link address, such as https://xxxxx.jmlk.co/AAaH.

config.callback (required)

  • Type: Function
  • Description: callback function. After initialization succeeds, link is passed to the upper layer. When opening the app, this link is passed to the app as a parameter. See the sample code in the demo.
  • Example:
callback: ({link}) => { this.setData({ parameter: link, }) }
           callback: ({link}) => {
 this.setData({
 parameter: link,
 })
 }

        
This code block is shown in the floating window

config.params

  • Type: Object
  • Description: parameters passed to the app, recommended. Users can use this parameter to pass parameters from the H5 page into the app. These parameters are not parameter placeholders configured in the JMLink service configuration in the Jiguang JMLink backend.

config.plhparams

  • Type: Object
  • Description: placeholder parameters passed to the app. These parameters must be parameter placeholders configured in the JMLink service configuration in the Jiguang JMLink backend; otherwise, they will be filtered out. If the app is installed, the parameters can be obtained when the app is opened. If this is the first installation, these parameters can be retrieved from our server through the Jiguang JMLink SDK API. For how the SDK implements JMLink, see the corresponding SDK documentation.
  • Example:
    1. URI Scheme configured in the backend mLink service: myapp://path/acticle?articleId=:id
    1. config.plhparams:{id: '123456' }
    1. Final URI Scheme: myapp://path/acticle?articleId=123456

config.invtparams

  • Type: Object
  • Description: invitation parameters, used to track the source.
  • Example: invtparams: {u_id: "uid-123456"}

Open App

click()

Call the SDK's click() method when clicking to open the app.

index.wxml: <button open-type="launchApp" app-parameter="{{parameter}}" bindtap="click" binderror="launchAppError">Open APP</button>
          index.wxml:
<button open-type="launchApp" app-parameter="{{parameter}}" 
bindtap="click" binderror="launchAppError">Open APP</button>

        
This code block is shown in the floating window
index.js: click: function() { this.data.sdk.click() }, // Executed when opening app fails launchAppError: function (e) { this.data.sdk.openAppError() }
          index.js:
 click: function() {
 this.data.sdk.click()
 },
 // Executed when opening app fails
 launchAppError: function (e) {
 this.data.sdk.openAppError()
 }

        
This code block is shown in the floating window
Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center