Initialization
#
Initialize ChatSDKTo 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.
#
Configure in app/build.gradle fileUpdate 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
.setMediaFolderName
should be defined your own local path folder name insteadofSELECT_YOUR_PATH_NAME
to maintain the Application Media files. If the argument is empty, SDK will be configured with default folder name asMirrorFly
.
- Java
- Kotlin
When Name of a user is available and their country code is available(needed only for mobile login) call the below methods wherever necessary.
- Java
- Kotlin
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).
#
Chat Builder Function DescriptionFunction | Parameter Type | Description |
---|---|---|
useProfileName | boolean | To show whether contact's profile name or nickname from sdk |
setDomainBaseUrl | String | url needed for api calls provided by Chat team |
enableMobileNumberLogin | boolean | true if mobile number is used as primary id for the user else false |
setLicenseKey | String | license key needed for registration api provided by Chat team |
setIsTrialLicenceKey | boolean | true if provided licence key is trial licence key else false |
setGroupConfiguration | GroupConfig | configuration for the group implementation |
setMediaFolderName | String | Folder Name needed to save for the Media Sent/Receive items in device storage |
setIVKey | String | The initial vector used for encryption/decryption |
build | n/a | initialize the chat configuration |
#
GroupConfig Builder Function DescriptionFunction | Argument Type | Description |
---|---|---|
enableGroupCreation | boolean | enable/disable group creation |
setMaximumMembersInAGroup | int | set the maximum number of members a group can have(cannot be greater than 300) |
onlyAdminCanAddOrRemoveMembers | boolean | if true only group admin can add/remove members else members can add/remove other members |
build | n/a | build GroupConfig object |
caution
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:
- Java
- Kotlin
#
RegistrationTo register a new user use the below method. This method will take care sandbox mode registration or live mode registration based on setIsTrialLicenceKey
provided.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
USER_IDENTIFIER | String | Unique Id to Register the User. We accept only the AlphaNumeric String |
FCM_TOKEN | String | fcm device token |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Connect to the chat serverIn 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.
Argument | Type | Description |
---|---|---|
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 |
- Java
- Kotlin
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.
- Java
- Kotlin