To start using the sdk, there were few data that were required by the SDK for initialization. For which we use the
ChatSDK builder class to provide data to SDK. In your
Application class onCreate build the ChatSDK Builder and provide the necessary data .An example can be found below.
Update your App License key in the app/build.gradle file. You can find the LICENSE key and paste your registered License Key. After replacing your license key do gradle sync operation.
Note : In ChatSDK Builder configuration
.setMediaFolderNameshould be defined your own local path folder name insteadof
SELECT_YOUR_PATH_NAMEto maintain the Application Media files. If the argument is empty, SDK will be configured with default folder name as
When Name of a user is available and their country code is available(needed only for mobile login) call the below methods wherever necessary.
when user decided to use mobile number for login by setting this flag to true using
enableMobileNumberLogin(true) method in ChatSDK, then country code must be provided for the sdk in the form of 2/3 letter code(ISO Alpha-2).
|useProfileName||To show whether contact's profile name or nickname from sdk|
|setDomainBaseUrl||url needed for api calls provided by Chat team|
|setLicenseKey||license key needed for registration api provided by Chat team|
|setGroupConfiguration||configuration for the group implementation|
|setMediaFolderName||Folder Name needed to save for the Media Sent/Receive items in device storage|
|setIVKey||The initial vector used for encryption/decryption|
|build||n/a||initialize the chat configuration|
|enableGroupCreation||enable/disable group creation|
|setMaximumMembersInAGroup||set the maximum number of members a group can have(cannot be greater than 300)|
|build||n/a||build GroupConfig object|
Base url must have http/https protocol and should end with
/ else an exception will be thrown.
In your application class
oncreate method add the below lines:
To register a new user use the below method. This method will take care sandbox mode registration or live mode registration based on
|USER_IDENTIFIER||Unique Id to Register the User|
|FCM_TOKEN||fcm device token|
In order to send messages using the chat sdk , at first you need to establish the connection to the server. sdk provides methods for initializing the connection configuration as well as methods for making connection.
At first initialize the connection details using the below method. This method will store the connection details in persistent storage to make connection automatically once you close and reopen the app.
|USERNAME||String||userName for making connection to the server|
|SECRET_KEY||String||password used to authenticate to the xmpp server|
|XMPP_DOMAIN||String||domain name which will be used in jid|
|XMPP_HOST||String||xmpp server url|
|XMPP_PORT||int||port of the xmpp server|
Once you initialized the connection details, for the first time you need to call the below method to make connection to the chat server immediately after that you don't need to call this method anymore, sdk will handle connection and disconnection on behalf of you.