No GUI interface call

1. Overview of GUI-less interface

github demo , the old version of SMSDemo
This article only introduces the use and precautions of the built-in (uninterfaced) methods of the SMS SDK. If you want to check the operation methods with an interface, please refer to the instructions in the relevant chapters of " SMS SDK Integration Documentation ".

Although the SMS SDK provides GUI functionality that simplifies the integration steps, it also allows developers to forgo this GUI and interact directly with the core code.
Studio: MobCommons-xxx.jar, MobTools-xxx.jar, SMSSDK-<version number>.aar
Eclipse: The core code of SMS SDK is stored in "SMSSDK-<version number>.jar" in SMSSDK/libs, when integrated In addition to copying SMSSDK-<version number>.jar to your own project libs, you should also copy MobCommons-xxx.jar, MobTools-xxx.jar and resource files, and the raw under res of SMSSDK should be copied to your project Under res; if the version is less than 2.0.1, do not copy raw, and copy libsmssdk.so.
The main external classes are: SMSSDK and EventHandler. All operations are initiated through SMSSDK and received through EventHandler. Since EventHandler has been described in the SMSSDK operation callback chapter , this section focuses on the various methods of SMSSDK.

 

2. No GUI interface description

2.1. Initialize the interface

Qualifiers and Types Methods and Descriptions
static void initSDK(Context context, String appkey, String appSecrect)
initializes SDK, singleton, can be called multiple times; before any method is called, it must be initialized first
static void registerEventHandler(EventHandler handler)
register callback interface
static void unregisterEventHandler(EventHandler handler)
unregister callback interface

The initSDK method is the entrance of the SMS SDK. It needs to pass the AppKey and AppSecre you registered in the ShareSDK application management background. If you fill in the wrong information, subsequent operations will not be performed.
registerEventHandler is used to register an event receiver with SMSSDK. SMSSDK allows developers to register any number of receivers, and all receivers will receive messages when the event is triggered.

SMSSDK.initSDK(this,APPKEY,APPSECRET);
		EventHandler eh=new EventHandler(){

			@Override
			public void afterEvent(int event, int result, Object data) {

			   if (result == SMSSDK.RESULT_COMPLETE) {
				//callback complete
				if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
                // Submit verification code successfully
				}else if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE){
			    // get the verification code successfully
				}else if (event ==SMSSDK.EVENT_GET_SUPPORTED_COUNTRIES){
                //Return the list of countries that support sending verification codes
                }
              }else{                                                                 
                 ((Throwable)data).printStackTrace();
          }
      }
   };
SMSSDK.registerEventHandler(eh); //register SMS callback

 

registerEventHandler must be used in conjunction with unregisterEventHandler, otherwise it may cause memory leaks.

2.2, SMS verification code interface

Qualifiers and Types Methods and Descriptions
static void getSupportedCountries()
gets the list of countries currently supported by SMS and returns it in the monitor
static void getVerificationCode(String country, String phone)
request to get SMS verification code and return it in the monitor
static void submitVerificationCode(String country, String phone, String code)
Submit the SMS verification code and return it in the monitor

The SMS SDK does not support SMS verification services in all countries in the world, so we provide the getSupportedCountries method. Please call this method before using the SMS verification code function to obtain the list of countries and number matching rules that the current SDK can support.
getVerificationCode is used to request the server to send a verification code. It needs to pass the country code and the mobile phone number for receiving the verification code. The country code that supports this service can be obtained from getSupportedCountries. The time interval for requesting getVerificationCode should not be less than 60 seconds, otherwise the server will return an error of "too frequent operation"
submitVerificationCode is used to submit the received SMS verification code to the server. After successful verification, the country code and phone number will be returned through EventHandler.

2.3. User interface

Qualifiers and Types Methods and Descriptions
static void submitUserInfo(String uid, String nickname, String avatar, String country, String phone)
submit user information and return it in the monitor
static void getNewFriendsCount()
gets the number of newly added friends in the app and returns it in the monitor
static void getFriendsInApp()
gets the friends list in the app and returns it in the monitor

The SMS verification code function of the SMS SDK can be regarded as a "third-party login" function. By checking the verification code, the accuracy of the mobile phone number can be obtained. After confirming the user's identity, the login and registration can be performed. After registering a user, the developer can submit user information to our server by calling the submitUserInfo method, and the submitted information will be used as the suggested information for the "Address Book Friend" function.
After submitting the user information, you can obtain the number of users in your app by calling getNewFriendsCount. And you can get the list of users in the current application in the device address book through getFriendsInApp.

2.4. Voice verification code interface

Qualifiers and Types Methods and Descriptions
static void For versions below 2.0.0, the first parameter is the mobile phone number. 

 

getVoiceVerifyCode(String phone , String country)

To be consistent with sending texts. 2.0.0 and later are changed to the first country code.

getVoiceVerifyCode(String country, String phone)
requests the voice verification code, and returns it in the monitor

The getVoiceVerifyCode method is mainly used for the second option when the SMS reception is relatively slow. It needs to pass the country code and the mobile phone number to receive the verification code. The voice verification code will be obtained by phone voice.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326750385&siteId=291194637