App SDK account management description
API Overview
Name | Description |
---|---|
Initialize | init |
Set Login Callback | addLoginListener |
Login with credential | login |
Quick login with verification code | fastLogin |
OAuth login | oauthLogin |
Login with saved credential | localLogin |
Send verification code | sendRegVCode |
Register account | regist |
Change password | modifyPassword |
Send verification code for password reset | sendRetrieveVCode |
Reset password | retrievePassword |
Edit nickname | modifyUserNickname |
Edit birthday and sex | modifyUserGenderBirthday |
Edit avatar | modifyUserIcon |
Query binding information | queryOauthBindInfo |
Binding account | bindOauthAccount |
Unbinding account | unbindOauthAccount |
Send Vcode for destroying account | sendDestroyCode |
Destroying account | destroyAccount |
1. Overview
BroadLink provides developers with interfaces for integration of account system. You can integrate account system by one of the following options:
Use BroadLink shared account system
- Choose BroadLink shared account system when you apply for license. This account is shared with ihc App (can be used for login on ihc).
Use BroadLink independent account system
- Choose BroadLink independent account system when you apply for license. This account is independent and isolated with other systems.
OAuth to BroadLink account system
- If you want to remotely control or access to BroadLink products from your own client’s App, you can invoke a BroadLink OAuth page for account linking. You will get information like accessToken and pass it to SDK for login.
OAuth to Client account system
- If you want to use third party account to log in to your App, you can use OAuth 2.0 to link your account to third party account on BroadLink cloud. You will get information like OpenID and AccessToken and pass them to SDK for login.
Login to account is required for remote control from external networks.
2. API Description
Account management interfaces will get necessary parameters CompanyId and Lid for initialization after initialization of BLLet class in BLLetCore library.
You can invoke [BLAccount sharedAccount]
in iOS to finish initialization.
You can invoke BLAccount.init(companyId, lid)
in static method in Android to finish initialization. Also you need to invoke the method in addLoginListener
to add listener for login information.
2.1 Initialize
public static void init(String companyid, String lid)
Request Parameter
Parameter Name | Parameter Type | Note | Is it necessary |
---|---|---|---|
companyid | String | The company ID returned from license application | Y |
lid | String | The license ID returned from license application | Y |
All the 2 parameters above can be returned by the method in BLLet.
//Simple Code
// Get lid and companyId after initialization for initialization of other libraries
String lid = BLLet.getLicenseId();
String companyId = BLLet.getCompanyid();
// Initialize account library
BLAccount.init(companyId, lid);
2.2 Set Login Callback
public static void addLoginListener(BLAccountLoginListener listener)
Request Parameter
Parameter Name | Parameter Type | Note | Is it necessary |
---|---|---|---|
listener | BLAccountLoginListener | Listener for login results | Y |
After login, you can pass the userId
and loginSession
from BLAccountLoginListener
.
//Simple Code
// Add callback function for login
BLAccount.addLoginListener(BLLet.Controller.getLoginListener());
BLAccount.addLoginListener(BLIRCode.getLoginListener());
BLAccount.addLoginListener(BLFamily.getLoginListener());
2.3 Log in Account
Account login is required for other operations. The SDK offers multiple ways for account login and returns class BLLoginResult.
You can save corresponding userId and loginSession according to your needs for future development.
BLLoginResult Description
PARAMETER NAME | PARAMETER TYPE | NOTE |
---|---|---|
userid | String | User ID |
loginsession | String | Login session |
nickname | String | User nickname |
iconpath | String | Avatar URL |
sex | String | User sex |
birthday | String | User birthday |
fname | String | User first name |
lname | String | User last name |
String | Email address | |
phone | String | User phone number |
countrycode | String | Country code for phone number, for example: 00852 |
loginip | String | IP address logged in |
logintime | String | Login time |
pwdflag | int | If user password is set |
2.3.1 Login with credential
public static BLLoginResult login(String username, String password)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
username | String | username | Y |
password | String | password | Y |
Return Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE |
---|---|---|
BLLoginResult | Object | Returned result |
2.3.2 Quick login with verification code
public static BLLoginResult fastLogin(String phoneOrEmail, String countrycode, String vcode)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phoneOrEmail | String | Phone number or email address | Y |
countrycode | String | Country code for phone number, for example: 00852 | It is necessary when you want to login in by phone number |
vcode | String | Verification code received | Y |
2.3.3 OAuth login
You can integrate third party OAuth SDK and login with their accounts using accessToken from their OAuth like Facebook,taobao.
public static BLLoginResult oauthLogin(String thirdType, String thirdID, String accesstoken, String topsign, String nickname, String iconUrl)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
thirdType | String | OAuth provider like Facebook | Y |
thirdID | String | OpenID from OAuth provider | Y |
accesstoken | String | AccessToken from OAuth provider | Y |
topsign | String | Currently is null | N |
nickname | String | Display name on App | N |
iconUrl | String | Avatar URL | N |
2.3.4 Login with saved credential
The user login session can be kept for long time so you can save the credential and pass it in for quick login next time.
If the session expired, it will return an error code and the user needs to log in again.
public static BLLoginResult localLogin(BLLoginResult loginResult)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
loginResult | Object | Returned result of last successful login | userId and loginsession are necessary |
2.4 Register Account
If you chose to use BroadLink independent account system, you can use phone number or email address to register an account.
2.4.1 Send verification code
public static BLBaseResult sendRegVCode(String phone, String countrycode);
public static BLBaseResult sendRegVCode(String email);
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phone | String | Phone number for registration | Y |
countrycode | String | Country code of phone number for registration | It is necessary when you want to login in by phone number |
String | Email address for registration | Y |
2.4.2 Register account
public static BLLoginResult regist(BLRegistParam registParam, File fileIcon)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
registParam | BLRegistParam | User information | Y |
fileIcon | File | User avatar | N |
Return Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE |
---|---|---|
BLLoginResult | Object | Returned result. Can be used for login after registration |
2.5 Password Related Interfaces
The password related functions include: Change password and reset password. Login to your account is required for changing password while resetting password does not need login.
2.5.1 Change password
public static BLBaseResult modifyPassword(String oldPassword, String newPassword)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
oldPassword | String | Old password | Y |
newPassword | String | New password | Y |
2.5.2 Send verification code for password reset
public static BLBaseResult sendRetrieveVCode(String phoneOrEmail);
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phoneOrEmail | String | Phone number or email address used in registration | Y |
2.5.3 Reset password
public static BLLoginResult retrievePassword(String phoneOrEmail, String vcode, String newPassword);
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phoneOrEmail | String | Phone number or email address used in registration | Y |
vcode | String | Verification code received | Y |
newPassword | String | Password after reset | Y |
2.6 User Info Related Interfaces
You can get complete user information from login result BLLoginResult after login. You can use the following interfaces to edit user information.
2.6.1 Edit nickname
public static BLBaseResult modifyUserNickname(String nickName)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
nickName | String | Nickname | Y |
2.6.2 Edit birthday and sex
public static BLBaseResult modifyUserGenderBirthday(String gender, String birthday)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
gender | String | Sex | Y |
birthday | String | Birthday | Y |
2.6.3 Edit avatar
public static BLModifyUserIconResult modifyUserIcon(File picFile)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
picFile | File | Avatar file | Y |
2.7 Oauth binding account
2.7.1 Query binding information
public static BLBindInfoResult queryOauthBindInfo()
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE |
---|---|---|
bindInfos | List |
Binding information list |
BindInfo Class information:
PARAMETER NAME | PARAMETER TYPE | NOTE |
---|---|---|
thirdtype | String | The Oauth name of third party |
thirdid | String | The Oauth ID of third party |
nickname | String | The nickname of third party |
2.7.2 Banding account
public static BLBaseResult bindOauthAccount(String thirdType, String thirdID, String accesstoken, String topSign, String nickname, String userId, String loginSession)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
thirdType | String | Oauth company of third party | Y |
thirdID | String | Oauth ID of third party | Y |
accesstoken | String | Oauth Token of third party | Y |
topSign | String | Oauth topSign of third party | N |
nickname | String | Oauth nickname of third party | N |
userId | String | login userid | N,The default is the current login account |
loginSession | String | loginSession | N,The default is the current login account |
2.7.3 Unbinding account
public static BLBaseResult unbindOauthAccount(String thirdType, String thirdID, String topSign)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
thirdType | String | Oauth company of third party | Y |
thirdID | String | Oauth ID of third party | Y |
topSign | String | Oauth topSign of third party | N |
2.8 Destroy account
2.8.1 Send Vcode for destroying account
public static BLBaseResult sendDestroyCode(String phoneOrEmail, String countryCode)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phoneOrEmail | String | Phone number or email address for registration | Y |
countrycode | String | Country code of phone number for registration | It is necessary when you want to login in by phone number |
2.8.2 Destroying account
public static BLBaseResult destroyAccount(String phoneOrEmail, String countryCode, String vcode)
Request Parameter
PARAMETER NAME | PARAMETER TYPE | NOTE | Is it necessary |
---|---|---|---|
phoneOrEmail | String | Phone number or email address for registration | Y |
countrycode | String | Country code of phone number for registration | It is necessary when you want to login in by phone number |
vcode | String | The Vcode received | Y |