1.1 Mini program management background add plug-in
- Log in to the WeChat public platform and click the Settings menu on the lower left
- Go to the Settings page and click the third-party Settings TAB
- In the plug-in management module, click the Add Plug-in button
- Search for
wxfp
, select the plug-in, and finish adding (If the application is urgent, the administrator can contact the developer for quick approval)
1.2 Integrate mini program code
1.app.json declares the plugin
{
"plugins": {
"tdfp-plugin": {
"version": "1.9.4",
"provider": "wxc3b909c3d24c5417"
}
},
}
- Note: The tripartite framework can be added accordingly. For example, in uni-app, you can add the above declaration to the mp-weixin module of the manifest.json file
- Initialize the plug-in js and necessary configuration
In app.js, partnerCode is the required parameter, appname and channel are optional fields:
const plugin = requirePlugin('tdfp-plugin')
App({
......
globalData: {
......
_fmOpt: {
partnerCode: "", // Please fill in your partner code
appName: "", // Please fill in your app name,Please fill in different appnames for different applets of the same company
channel:"", // Please fill in your channel
}
},
onLaunch(){
let fmagent = new plugin.FMAgent(this.globalData._fmOpt)
fmagent.init()
}
......
})
- Get BlackBox
Our device fingerprint SDK adopts a call mode similar to WeChat API and supports passingsuccess
,fail
,complete
callback, and other configuration fields:
const plugin = requirePlugin('tdfp-plugin')
var that = this
var fmagent = new plugin.FMAgent(app.globalData._fmOpt)
fmagent.getInfo({
page: that, // The Page or Component object where FMAgent resides
mode:'plugin',
openid: '', // If openid or unionid is empty or undefined, do not encrypt upload, pass an empty string
// If you have the unionid function enabled, pass in the encrypted user unionid
// Please pass in the encrypted openid of the user (ensure that the encrypted openid is one-to-one corresponding to the original openid).
unionid: '',
success: function (res) {},//Successful callback, res is BlackBox string
fail: function (res) {},// Failure callback, res for various exception objects
complete: function (res) {} //Complete callback, res for BlackBox string or various exception objects
})
Parameter Description
parameter | type | describe | sample | Required | Remove Field |
---|---|---|---|---|---|
page | Object | The page object or a component object that you are currently in | that | Yes | |
openid | String | User openid after encryption (encryption algorithm can be selected at will, please ensure one-to-one correspondence before and after encryption, MD5 or SHA256 is recommended) (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur) | ef54040ea9cb599823077 | Yes | |
mode | String | docking mode(Please pass in' plugin' for plug-in access, and ignore the sdk mode) | 'plugin' | No | |
unionid | String | User unionid after encryption (encryption algorithm can be selected at will, please ensure one-to-one correspondence before and after encryption, MD5 or SHA256 is recommended) (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur)) | ef54040ea9cb599823077 | No | |
timeout | Number | Get BlackBox timeout (default: 2500, including the total duration of collecting and sending requests, range: 2500-16000,Unit: ms) | 6000 | No | |
getInfoType | string | Get blackbox mode ('1' : use cached blackbox first, '2' : use real-time collection blackbox first, '3' : use unexpired blackbox first to expire, default mode is '1') | '1' | ||
getLocationAllowed | Boolean | Whether to collect location information. If you need to collect location information, please contact the operation to obtain privacy compliance guidance (The default is false. If you need to collect, please obtain the authorization of wechat and mini program location information in advance and set the current item to true). | false | No | latitude、longitude |
noClipboard | Boolean | Whether not to collect the clipboard (some phones will have the system prompt that the clipboard has been collected, and the clipboard can partially enhance our recovery ability) The default is true | false | No | lipboard |
success | Function | Successful callback | function(res) {/res for BlackBox string /} | Yes | |
fail | Function | Failed callback | function(res) {/res for various exception objects /} | No | |
complete | Function | Complete callback | function(res) {/res for BlackBox string or various exception objects /} | No |
Note:
- blackbox has an expiration date, so please do not cache blackbox yourself, there is a caching mechanism inside our SDK, so please call the getInfo interface where you need blackbox
- Degrade The blackbox length ranges from 3000 to 5000 bytes. You are advised to report the blackbox to the body
- If you need the sdk version integration method, please contact the operation support