SMS verification code SDK, which provides developers with a universal SMS verification code tool, and developers can use it to implant SMS verification codes in the App
SDK, simple settings can realize SMS verification function, the integration is fast and convenient, and it is easy to manage later.

Before configuring the integrated developer to use this module, you need to go to the Mob official website to apply for a developer account, and fill in the corresponding information in the account to create your own APP, so as to obtain the AppKey and AppSecret, and then add the SMSSDK function to obtain the template id. For details, please refer to: Quick integration to obtain Appkey and AppSecret

Preparation

Download and install the development tools: APICloud Studio 2

Create an app

APICloud provides two ways to create applications, which is convenient for developers to create applications in the cloud or in APICloud Studio. Create an application in the cloud:

(1) Register and log in to the APICloud system: https://www.apicloud.com/console Click "Create Application" in the upper left corner, as shown in the figure: Select "Native", fill in "Name" and "Description", and the application is created.

Create an application in APICloud Studio:

(2) Log in to APICloud Studio, if you do not have an account, click "Register Account", already registered, log in to APICloud Studio with the previously registered APICloud account

These 2 terminals can synchronize information with each other:

Synchronize the local application to the cloud repository, and the application created by the developer in APICloud Studio will establish a connection with the cloud repository. After the project code is changed, you can use the code submission function of APICloud Studio to submit the code to the cloud repository.

add module

Open APICloud, since version 1.2.0, the smssdk module also depends on the mobcommonlib module, so you need to search for the mobcommonlib module in the module library and add it to the added module.

Note: Starting from version 1.2.0, the use of SMS SDK requires access to the privacy function. For the access method of the privacy function, please refer to the documentation of the mobcommonlib module.

在这里插入图片描述

Module usage guide
Android: Before using this module, android needs to configure the config.xml file, the method is as follows

 <meta-data name="Mob-AppKey" value="moba6b6c6d6"/>
<meta-data name="Mob-AppSecret" value="b89d2427a3bc7ad1aea1e1e8c1d36bf3"/>

iOS: iOS needs to put the Info.plist file in the res directory, the content of the file:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MOBAppKey</key>
<string>moba6b6c6d6</string>
<key>MOBAppSecret</key>
<string>b89d2427a3bc7ad1aea1e1e8c1d36bf3</string>
</dict>
</plist>

Field description:

  • Mob-AppKey: (must be configured) AppKey obtained from MobTeck official website.
  • Mob-AppSecret: (must be configured) AppSecret obtained from MobTech official website. For the application method, please refer to Quick Integration for AppKey and AppSecret .

When compiling the APP for iOS, please configure the permission to access contacts

Demo instance widget download address

Get text verification code (getTextCode)

Modules need to be imported: var moduleSMSSDK = api.require('smssdk');

getTextCode({params}, callback(ret,err)) params:

 phoneNumber:

类型:字符串

默认值:无

描述:手机号

zone:

类型:字符串

默认值:无

描述:区域号,不要加"+"号

tempCode:

类型:字符串

默认值:无

描述:模板id

callback(ret,err) ret:

Type: JSON Object

Internal field: { smart:0 //whether it is a smart validation bool type, ios ignores this field}

err:

Type: JSON Object

Internal fields:

 {
    code:0    //错误码(详见错误码常量)
    msg:""    //错误描述
};

sample code

 var param = {zone:'86', phoneNumber:'18500000000',tempCode:'1319972'};
moduleSMSSDK.getTextCode(param, function(ret, err){
    if (err !== null && err !== undefined && err !== '') {
     // 错误消息示例:{"msg":"Template not exist.","code":484}
    alert("Error:\n" + JSON.stringify(err));
    } else {
        // 正常消息示例:{"smart":false}
       alert("Success:\n" + JSON.stringify(ret));
    }
    });

Get Voice Verification Code (getVoiceCode)
getVoiceCode({params}, callback(ret, err)) params:

 phoneNumber:

类型:字符串

默认值:无

描述:手机号

zone:

类型:字符串

默认值:无

描述:区域号,不要加"+"号

callback(ret, err) ret:

Type: JSON Object Internal Fields: { }

err:

Type: JSON Object

Internal fields:

 {
    code:0    //错误码(详见错误码常量)
    msg:""    //错误描述
};

Sample code:

 // param中的key命名不能改变
var param = {zone:'86', phoneNumber:'18500000000'};
moduleSMSSDK.getVoiceCode(param, function(ret, err){
  if (err !== null && err !== undefined && err !== '') {
   // 错误消息示例:{"msg":"Template not exist.","code":484}
   alert("Error:\n" + JSON.stringify(err));
  } else {
     // 正常消息示例:{}
    alert("Success:\n" + JSON.stringify(ret));
    }
   });

Submit verification code (commitCode)

commitCode({params}, callback(ret, err)) params:

 phoneNumber:

类型:字符串

默认值:无

描述:手机号

zone:

类型:字符串

默认值:无

描述:区域号,不要加"+"号

code:

类型:字符串

默认值:无

描述:验证码

callback(ret, err) ret:

Type: JSON Object Internal Fields: { }

err:

Type: JSON Object

Internal fields:

 {
    code:0    //错误码(详见错误码常量)
    msg:""    //错误描述
};

Sample code:

 // param中的key命名不能改变
var param = {zone:'86', phoneNumber:'18500000000', code:'4847'};
moduleSMSSDK.commitCode(param, function(ret, err){
if (err !== null && err !== undefined && err !== '') {
  // 错误消息示例:{"msg":"Template not exist.","code":484}
  alert("Error:\n" + JSON.stringify(err));
  } else {

  }
  });

Get the area code (getSupportedCountries)

getSupportedCountries(callback(ret, err)) callback(ret, err) ret:

Type: JSON Object

Internal fields:

 {
    countries =
    (
        {
        rule = "^\\d+";
        zone = 1868;
        }
    )
}

err:

Type: JSON Object

Internal fields:

 {
    code:0    //错误码(详见错误码常量)
    msg:""    //错误描述
};

Sample code:

 // param中的key命名不能改变
moduleSMSSDK.getSupportedCountries(function(ret, err){
    if (err !== null && err !== undefined && err !== '') {
     // 错误消息示例:{"msg":"Template not exist.","code":484}
      alert("Error:\n" + JSON.stringify(err));
     } else {
      // 正常消息示例:{"countries":[{zone=590, rule=^\d+},{zone=680, rule=^\d+}]}
        alert("Success:\n" + JSON.stringify(ret));
    }
  });

Submit User Info (submitUserInfo)

submitUserInfo({params}, callback(ret, err)) params:

 uid:
类型:字符串
默认值:无
描述:用户id

nickname:
类型:字符串
默认值:无
描述:用户昵称

avatar:
类型:字符串
默认值:无
描述:头像地址

phoneNumber:
类型:字符串
默认值:无
描述:手机号

zone:
类型:字符串
默认值:无
描述:区域号,不要加"+"号

callback(ret, err) ret:

Type: JSON Object

Internal field: { }

err:

Type: JSON Object

Internal fields:

 {
    code:0    //错误码(详见错误码常量)
    msg:""    //错误描述
};`

Sample code:

 // param中的key命名不能改变
var uid = "3241241";
var nickname = "SmsSDK_Api_Cloud_User_" + uid;
var avatar = "https://download.sdk.mob.com/510/deb/0c0731ac543eb71311c482a2e2.png";
// param中的key命名不能改变
var param = {uid:uid, nickname:nickname, avatar:avatar, phoneNumber:'18500000000', zone:'86'};

moduleSMSSDK.submitUserInfo(param, function(ret, err){
if (err !== null && err !== undefined && err !== '') {
// 错误消息示例:{"msg":"Template not exist.","code":484}
alert("Error:\n" + JSON.stringify(err));
} else {
}
});

Get the version number (getVersion)

getVersion(callback(ret, err)) callback(ret, err) ret

Type: JSON Object

Internal field: { version: "1.0.0" }

err

Type: JSON Object

Internal field: { }

Sample code:

 // param中的key命名不能改变
moduleSMSSDK.getVersion(function(ret, err){
   if (err !== null && err !== undefined && err !== '') {
       // 错误消息示例:{"msg":"Template not exist.","code":484}
       alert("Error:\n" + JSON.stringify(err));
   } else {
      // 正常消息示例:{"version":'3.2.2'}
   }
});

中关村科金
136 声望13 粉丝

北京中关村科金技术有限公司(简称“中关村科金”)是国内领先的对话式AI技术解决方案提供商,成立于2014年,注册资本14亿元,总部位于北京,在上海、重庆、深圳、杭州、成都等地设有分支机构,公司规模近千人,其...


引用和评论

0 条评论