WeChat Mini Program SDK Integration Guide

Last updated:2023-02-21
Expand all
WeChat Mini Program SDK Integration Guide

Usage Notes

This document is the standard integration guide for JOperate WeChat Mini Program SDK.

The matched SDK version is v2.0.0 and later.

  • If you want to quickly test it, refer to this document to run the demo within a few minutes.
  • The Jiguang Push documentation site contains all related guides, APIs, tutorials, and other documentation. Updated versions of this document will also be published on that site in a timely manner.

Product Description

Use event templates to collect app user behavior events and report them to Jiguang servers. Jiguang displays processed data to developers through WebPortal, helping developers better understand how users use their applications.

Obtain App Information

After completing data source integration, go to "Data Source List - Details" to view the AppKey and scheme. For details, see WeChat Mini Program Platform Integration.

Configuration Steps

Local Project Configuration

Unzip the joperate-m-x.x.x-release.zip package and place files under libs into your project. The directory can be customized, for example copied under the project.

  • libs/joperate-m-x.x.x.js
  • SDK operate package
  • libs/joperate-conf.js
  • SDK operate configuration file
  • demo
  • A complete Mini Program project that demonstrates the basic usage of the JOperate SDK and can be used as a reference.

Configure joperate-conf.js

Configure SDK integration information in joperate-p-conf.js and enable debug mode. Example:

exports.appKey = ""; // appkey assigned after creating an app on the Jiguang official website, required exports.appid = ""; // appid assigned by the WeChat admin backend, required exports.channel = "default-channel"; // Channel name. Default value: default-channel exports.debugMode = true; // Whether to enable debug mode. true prints more log information. false outputs only w and e level logs.
          exports.appKey = ""; // appkey assigned after creating an app on the Jiguang official website, required
exports.appid = ""; // appid assigned by the WeChat admin backend, required
exports.channel = "default-channel"; // Channel name. Default value: default-channel
exports.debugMode = true; // Whether to enable debug mode. true prints more log information. false outputs only w and e level logs.

        
This code block is shown in the floating window

Configure npm

  • Configure required encryption and compression components in the Mini Program package.json file.
"dependencies": { "crypto-js": "^3.1.9-1", "pako": "^1.0.6", "wxmp-rsa": "^2.1.0" }...
           "dependencies": {
 "crypto-js": "^3.1.9-1",
 "pako": "^1.0.6",
 "wxmp-rsa": "^2.1.0"
 }...

        
This code block is shown in the floating window
  • Click Tools -> Build npm to complete npm configuration.

Configure Valid Request Domains

In WeChat Official Platform development settings, add the following valid request domains:

  • https://smartop-sdkapi.jiguang.cn
  • https://mini-stats.jpush.cn
  • https://user.jpush.cn

SDK Initialization

  • Import the SDK in app.js and call the initialization API:
var _joperate = require('./joperate-m-2.0.0.js') App({ onLaunch: function () { ··· // Call initialization in app onLaunch _joperate.init(this) }, globalData: { joperate:_joperate } ··· })
          var _joperate = require('./joperate-m-2.0.0.js') 

App({
 onLaunch: function () {
     ···
     // Call initialization in app onLaunch
     _joperate.init(this)
 },
 globalData: {
 joperate:_joperate
 }
 ···
})

        
This code block is shown in the floating window

After initialization is called in app.js onLaunch, it can be used by every page. No repeated import is required. When needed, use app.globalData.joperate to call SDK-related methods.

Data Verification Mode

If you need to view real-time reporting, scan the code to enter data verification mode. For details, see Data Verification Documentation.

More APIs

For usage of other APIs, see the API documentation: MiniProgram SDK API

Run Demo

The example included in the package is an API demo. You can run it directly for testing. For running instructions, see Mini Program official documentation.

Technical Support

Email: support@jiguang.cn

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