Web SDK API
SDK Initialize
window.JVerificationInterface.init(Object)
Description
Initialization interface.
Parameters
Initializing Parameters Object Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| appkey | string | Jiguang console distribution. appkey(Prescribed) |
| debugMode | boolean | Whether to open debug Mode, Default false |
| domainName | string | Developer domain name |
| success | function | Interface calls a successful callback function |
| fail | function | An interface calling failed callback function |
Rewind Object data Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| code | number | Return code 0 for success, other failures, referenceError Code |
| message | string | ResultDescription |
Example
window.JVerificationInterface.init({
appkey: "极光后台Registration的 appkey",
debugMode: true,
domainName:"https://minio-sdk-res.qa.jpushoa.com",//since5.0.0 开发者域名 已极光的 DEMO 域名为例
success: function(data) {
//TODO 初始化成功回调
},
fail: function(data) {
//TODO 初始化失败回调
}
});
Access SDK Successful initialization identifier
window.JVerificationInterface.isInitSuccess()
Description
Access SDK Whether or not the whole initialization of the successful marking. SDK Uninitialized, Initializing and Returns when initialization failed false。
Return value
boolean: true - Success.false - Failed.
Example
var isSuccess = window.JVerificationInterface.isInitSuccess();
SDK Assess whether the network environment supports
window.JVerificationInterface.checkVerifyEnable()
Description
Determines whether the current equipment environment can use authentication. The current device environment is mobile and the network environment is not wifi Optional, with an accuracy problem.
Return value
boolean: true - Success.false - Failed.
Example
var verifyEnable = window.JVerificationInterface.checkVerifyEnable();
if(!verifyEnable){
console.log("当前网络环境不支持认证");
return;
}
SDK To judge whether the web environment is a cellular network.
window.JVerificationInterface.isCellular()
Description
To judge whether the current equipment environment is a cellular network. The current device network is a cellular network, not a wifi Optional, with an accuracy problem.
Return value
boolean: true - Success.false - Failed.
Example
var isCellular = window.JVerificationInterface.isCellular();
if(!isCellular){
console.log("当前网络环境不是蜂窝网络");
return;
}
SDK To judge whether the network environment isWiFiNetwork
window.JVerificationInterface.isWifi()
Description
Determine whether the current equipment environment isWiFiNetwork. The current device network environment isWiFiNetwork,wifi Not supported at all. Optional, with an accuracy problem.
Return value
boolean: true - Success.false - Failed.
Example
var isWifi = window.JVerificationInterface.isWifi();
if(isWifi){
console.log("当前网络环境是WiFi网络");
return;
}
SDK Access number authentication token
window.JVerificationInterface.getToken(Object)
Description
Get Current Online sim Carcass.Carrierand token。 If a successful representative can be used to authenticate a cell phone number, several attempts to obtain a failed call suggest texting confirmation,CarrierDefault timeout is 5000ms。
Parameters
Access token Parameters Object Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| operater | string | Set priority to try to get token CarrierCM for China, CU for China Connect, CT for China Telecommunications |
| success | function | Interface calls a successful callback function |
| fail | function | An interface calling failed callback function |
Rewind Object data Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| code | number | Return code 0 for success, other failures, referenceError Code |
| message | string | ResultDescription |
| operater | string | This is the parameter when it succeeds.CarrierCM for China, CU for China Connect, CT for China Telecommunications |
| content | string | When successfulCarrier token |
Example
window.JVerificationInterface.getToken({
operater:"CM"
success: function(data) {
//TODO 获取 token 成功回调
var operater =data.operater;
var token =data.content;
}, fail: function(data) {
//TODO 获取 token 失败回调
}
})
Other notes
Move in Fetching token failed origin and referer(Contributions completed when requesting a mobile account) returns if there is a discrepancy in the mobile authentication500failed token function.
- origin: Web domain name.
- referer: Web source, usually the current site,iOS safari It could be intercepted for real. referer Yes.
SDK One-Tap Login
window.JVerificationInterface.loginAuth(Object)
Description
One-Tap LoginInterface
One-Tap LoginThe default style is: 4 bits in the middle of the cell phone number to be filled by the user
** From 5.3.0 It's starting. Mobile, connectivity, telecommunications.Carrier SIM The card supports "no need to fill in the center 4 bits, mask directly."LoginThe effect, if necessary, please.Contact sales。**
Parameters
One-Tap LoginParameters Object Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| operater | string | Set priority to try to get token CarrierCM for China, CU for China Connect, CT for China Telecommunications |
| type | string | Set PageLoginmode, full screen:fullThe bullet window:dialogDo not fill the default full screen |
| timeout | number | One-Tap LoginInterface calls timeout, default9000ms, set range[5000,20000] |
| success | function | Interface calls a successful callback function |
| fail | function | An interface calling failed callback function |
Rewind Object data Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| code | number | Return code 0 for success, other failures, referenceError Code |
| message | string | ResultDescription |
| operater | string | This is the parameter when it succeeds.CarrierCM for China, CU for China Connect, CT for China Telecommunications |
| content | string | When successfulCarrierOne-Tap Login token |
Example
window.JVerificationInterface.loginAuth({
operater:"CM",
type:"full",
success: function(data) {
//TODO 一键Login获取 token 成功回调
var operater =data.operater;
var token =data.content;
}, fail: function(data) {
//TODO 一键Login获取 token 失败回调
}
})
Other notes
- No masked version of telecommunications does not support settingslogo and Application name.
SDK One-Tap Login UI Settings
window.JVerificationInterface.setCustomUIWithConfig(Object)
Description
Set one-tap login UI Interface
Parameters:
Access token Parameters Object Note:
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| logo | string | Set one-tap login logo, size suggested: full screen mode (80x80, the bullet window mode ()60x60) |
| appName | string | Set one-tap loginApply Name |
| loginBtnColor | string | Loginbutton#9400D3' |
| loginTextColor | string | LoginButton font colours, such as '#9400D3' |
| customPolicyLink1 | [] | |
| customPolicyLink2 | [] | |
| customPolicyLink3 | [] | |
| customPolicyLinkColor | string | protocol color, like '#9400D3' |
| isDisplayOtherWayBtn | bool | Whether to show otherLoginmode button, defaultfalse; telecommunications are not supported;5.3.0Version started moving unsupported |
| customOtherWayTextColor | string | OtherLoginstyle button text colour, e. g. '#9400D3' |
Example:
window.JVerificationInterface.setCustomUIWithConfig({
logo:"https://opencloud.wostore.cn/h5netauth/h5auth_demo/img/logo3.png",
appName:"测试应用名称"
})
No Mask UI Mode
One-Tap LoginNo Mask UI Mode
Description
By adding specifics to the page div Label to control one-tap loginThe display of the bullet window. UI styles are identical in both modes
Supported version
Supported since version 5.3.1
Presentation mode description:
| Mode | Conditions | Annotations |
|---|---|---|
| Maskless Mode | This tab exists on the page | Bullet window embedded in page, scrolls with page |
| Standard bullet window mode | This tab does not exist on the page | Blast windows over the page with a mask |
Example
<!-- 添加标签启用无遮罩模式 -->
<div id="ydrzCustomControls"></div>
Other notes
SDK Event listening
window.JVerificationInterface.addEventListen(Object)
Description
Add user click event listening, current 5.3.0 For mobile, connected, telecommunicationsLoginThe interface returns,5.2.1 The following version only applies to mobile and connectedLoginInterface returns.
Parameters:
| code | message | Notes |
|---|---|---|
| 3001 | Click to close the page | Effective after call on event listening interface |
| 3002 | Agreed terms | Effective after call on event listening interface |
| 3003 | Non-consensual terms of agreement | Effective after call on event listening interface |
| 3004 | Start Input | After calling the event listening interface, it becomes effective.5.3.0Version started moving unsupported |
| 3005 | Input Completed | Effective after call on event listening interface |
| 3006 | Hit.Login | Effective after call on event listening interface |
| 3007 | Click otherLoginbutton | After calling the event listening interface, it becomes effective.5.3.0Version started moving unsupported |
| 3008 | LoginInterface Popup | Effective after call on event listening interface |
Example:
window.JVerificationInterface.addEventListen({
event: function(data) {
console.log("example addEventListen:"+JSON.stringify(data))
}
})
Error Code
| code | message | Notes |
|---|---|---|
| 0 | success | Call Success |
| 1000 | unknown error | Unknown error |
| 1001 | initing, please try again later | Initializing. Try again later. |
| 1002 | empty appkey | appkey empty |
| 1003 | init failed | Initialization failed, detailed reference console printing |
| 1004 | init timeout | Initialization timeout |
| 1005 | no internet | Current no network connection |
| 2001 | please call init correctly first | SDK Not initialized, call first successfully init() Methodology |
| 2002 | getToken faild | Access token Failed, this error corresponds content We'll carry each other.CarrierError message |
| 2003 | token requesting, please try again later | Fetching token I'll try again later. |
| 2004 | not support | Current environment does not support access token |
| 2005 | operater has to be one of CM,CT,CU | Access token operater Reference Error |
| 2006 | Login Auth Time Out | loginAuthInterface call timeout |
When code is 2002 content Parameters
| Parameter Name | Parameter Type | Parameters |
|---|---|---|
| CM | string | Move Access token FailedDescription |
| CU | string | Connect to access token FailedDescription |
| CT | string | Access to telecommunications token FailedDescription |