1. Adding a Domain Name
In Settings
- development Settings
- server domain
request legal domain
add:
Environment | Domain name |
---|---|
Production(required) | https://fp.tongdun.net |
Note:
- 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
<view>
<canvas id='tdcanvas' style="visibility: hidden;position: fixed;z-index: -999;left: 9999px;"></canvas>
</view>
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
App({
......
globalData: {
......
_fmOpt: {
partnerCode: "", // Please fill in your partner code
appName: "", // Please fill in your app name
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:
fmagent.getInfo({
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
parameter | type | describe | sample | Required | Remove Field |
---|---|---|---|---|---|
page | Object | The page object or a component object that you are currently in | that | Yes | |
unionid | String | User unionid (remember that custom default value cannot be passed, no value please pass an empty string, otherwise collision will occur)) | ef54040ea9cb5998230777ec7240b21e400a7ab5272af07a9ca2ed958fe66157 | 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' | No | |
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 | clipoard |
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 |