1. Adding a Domain Name

In Settings - development Settings - server domain request legal domain add:

EnvironmentDomain name


  • If the online version applet will only access the same production environment, add the first production domain name
  • The Fingerprint SDK for Tongdun bytedance mini program devices only supports wechat clients with the version of the client base library (SDKVersion, obtained through tt.getSystemInfo API) above 1.15.0

2. Insert canvas node

Import in the corresponding ttml file that needs to call the sdk

    <canvas id='tdcanvas' style="visibility: hidden;position: fixed;z-index: -999;left: 9999px;"></canvas>

Note: You are advised to introduce it as a component

3. Initialization

Our device fingerprint object lives in the lifecycle of a Page (or Component), so an instance needs to be created for each page that needs to get device information. For example, in pages/index/index.js, first reference the SDK file at the top of the file:

import FMAgent from '../../fmsdk/fm-xxx-es.saas.js'

Initialize the object in the onLoad callback of the Page:

onLoad: function() {
	var that = this
	var fmagent = new FMAgent(app.globalData._fmOpt) // Some necessary configurations

Configuration of FMAgent
In the globalData of the app object in the app.js file

	globalData: {
		_fmOpt: {
			partnerCode: "", // Please fill in your partner code
			appName: "", // Please fill in your app name
			// The following values need to be set only when it is confirmed to be a production environment. The following configurations need to be deleted in the sandbox environment
			env: "PRODUCTION"

After the initialization is successful, you can see a log on the console:
FMAgent: init succeeded.

4. Get blackBox

After the device fingerprint object is initialized, the device information can be obtained. Our device fingerprint SDK adopts a call mode similar to wechat API, and supports passing success, fail, complete callback, and other configuration fields:

    page: that, // The Page or Component object where FMAgent resides
    unionid: '', // User id
    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

API Parameter Description

pageObjectThe page object or a component object that you are currently inthatYes
unionidStringUser unionid (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur))ef54040ea9cb5998230777ec7240b21e400a7ab5272af07a9ca2ed958fe66157No
timeoutNumberGet BlackBox timeout (default: 2500, including the total duration of collecting and sending requests, range: 2500-16000,Unit: ms)6000No
getInfoTypeStringGet 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'No
noClipboardBooleanWhether 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 truefalseNo
successFunctionSuccessful callbackfunction(res) {/res for BlackBox string/}Yes
failFunctionFailed callbackfunction(res) {/res for various exception objects /}No
completeFunctionComplete callbackfunction(res) {/res for BlackBox string or various exception objects/}No