Last updated:
0 purchases
applozic flutter
Applozic flutter chat plugin #
A flutter wraper for Applozic native android and iOS SDKs.
Getting Started #
Sign up for Applozic to get your application Id. This application Id is used to login user to applozic.
Prerequisites #
Apps using Applozic can target Xcode 13 or later and AndroidX is required.
Installation #
Add the below dependency in your pubspec.yaml file:
dependencies:
# other dependencies
applozic_flutter: ^0.2.0
copied to clipboard
Install the package as below:
flutter pub get
copied to clipboard
For iOS, navigate to your App/iOS directory from terminal and run the below command:
pod install
copied to clipboard
Note: Applozic iOS requires min iOS platform version 12 and uses dynamic frameworks. Make sure you have the below settings at the top of your iOS/Podfile:
platform :ios, '12.0'
use_frameworks!
copied to clipboard
Import the applozic_flutter in your .dart file to use the methods from Applozic:
import 'package:applozic_flutter/applozic_flutter.dart';
copied to clipboard
Authentication #
Login #
Create Applozic user and pass user to login() function as below:
dynamic user = {
'applicationId': "<APPLICATION_ID>", //Mandatory
'userId': userId.text, //Mandatory
'displayName': displayName.text,
'password': password.text,
'authenticationTypeId': 1 //Mandatory
};
ApplozicFlutter.login(user).then((response) {
print("Login success : " + response)
}).catchError((error, stack) =>
print("Error while logging in : " + error.toString()));
copied to clipboard
Note: Please remember you have to log in once and only after you log out you must log in again. Use below code to check if the user is already logged in:
ApplozicFlutter.isLoggedIn().then((isLoggedIn) {
if (isLoggedIn) {
//The user is logged in
} esle {
//The user is not logged in
}
});
copied to clipboard
Update logged in user details #
You can update the logged in user details as below:
dynamic user = {
'displayName': '<New name>'
'imageLink': '<New Image URL>'
}
ApplozicFlutter.updateUserDetail(user)
.then(
(value) => print("User details updated : " + value))
.catchError((e, s) => print(
"Unable to update user details : " + e.toString()));
copied to clipboard
Get logged in userId #
You can get the userId of the logged in user as below:
ApplozicFlutter.getLoggedInUserId().then((userId) {
print("Logged in userId : " + userId);
}).catchError((error, stack) {
print("User get error : " + error);
});
copied to clipboard
Push Notifications #
Refer to this doc link for push notification for Android and iOS
Conversation #
Launch main chat screen #
Launch the main chat screen as below:
ApplozicFlutter.launchChatScreen();
copied to clipboard
Launch Chat with a specific User #
Launch the conversation with a user by passing the userId as below:
ApplozicFlutter.launchChatWithUser("<USER_ID>");
copied to clipboard
Launch Chat with a specific Group #
Launch the conversation with a group by passing the groupId as below:
ApplozicFlutter.launchChatWithGroupId(<GROUP_ID>)
.then((value) =>
print("Launched successfully : " + value))
.catchError((error, stack) {
print("Unable to launch group : " + error.toString());
});
copied to clipboard
Create a group #
To create a group, you need to create a groupInfo object and then pass it to the create group function as below:
dynamic groupInfo = {
'groupName': "My group",
'groupMemberList': ['userId1', 'userId2'],
'imageUrl': 'https://www.applozic.com/favicon.ico',
'type': 2,
'admin': 'userId1',
'metadata': {
'plugin': "Flutter",
'platform': "Android"
}
};
ApplozicFlutter.createGroup(groupInfo)
.then((groupId) {
print("Group created sucessfully: " + groupId);
ApplozicFlutter.launchChatWithGroupId(groupId)
.then((value) => print("Launched successfully : " + value))
.catchError((error, stack) {
print("Unable to launch group : " + error.toString());
});
})
.catchError((error, stack) =>
print("Group created failed : " + error.toString()));
copied to clipboard
Add member to group #
To add a member to a group you need to great a object with userId of the member to add and the groupId/clientGroupId (either one) of the group:
dynamic detailObject = {
'userId': "userId", //userId of the user to add
'groupId': 123456 //groupId of the group to add the user to
};
copied to clipboard
Then pass the object to this function:
ApplozicFlutter.addMemberToGroup(detailObject)
.then((value) => {
print("Member added successfully."),
ApplozicFlutter.createToast("Member added successfully.")
})
.catchError((e, s) => {
print("Error adding member."),
ApplozicFlutter.createToast("Error in adding member.")
});
copied to clipboard
Remove member from group #
To add a member to a group you need to great a object with userId of the member to add and the groupId/clientGroupId (either one) of the group:
dynamic detailObject = {
'userId': "userId", //userId of the user to remove
'groupId': 123456 //groupId of the group to remove the user from
};
copied to clipboard
Then pass the object to this function:
ApplozicFlutter.removeMemberFromGroup(detailObject)
.then((value) => {
print("Member removed successfully."),
ApplozicFlutter.createToast("Member removed successfully.")
})
.catchError((e, s) => {
print("Error removing member."),
ApplozicFlutter.createToast("Error in removing member.")
});
copied to clipboard
Send message #
To send a message to a contact or a group, you must first create a message object:
dynamic message = {
'to': "userId", // to send message to a contact pass the userId of the receiver (You can ignore the groupId in this case)
'groupId': groupId, //to send message to a group pass the groupId (You can ignore the userId in this case)
'message': "message text", // message to send
};
copied to clipboard
Note: A message object can have more parameters. Refer to this link: https://docs.applozic.com/docs/android-chat-message-api#build-your-ui-from-scratch---message-api
Then pass the message object to this function:
ApplozicFlutter.sendMessage(message)
.then((value) => print("Message sent."))
.catchError((e, s) => print("Error while sending message: " + e.toString()));
copied to clipboard
Unread message count for contact #
To get the unread count for contact, pass the userId of the contact to the function:
ApplozicFlutter.getUnreadCountForContact(userId)
.then((value) => print("Unread count : " + value.toString()))
.catchError((e, s) => print("Error."));
copied to clipboard
Unread message count for channel #
To get the unread count for a channel, create a object with either the groupId or the clientGroupId (only one required):
dynamic channelDetails = { //you need to provide only one of the two
'groupId' : 123456,
'clientGroupId' : "clientGroupId"
};
copied to clipboard
The pass the object to this function:
ApplozicFlutter.getUnreadCountForChannel(channelDetails)
.then((value) => print("Unread count : " + value.toString()))
.catchError((e, s) => print("Error."));
copied to clipboard
Number of unread chats #
Simply call the following function:
ApplozicFlutter.getUnreadChatsCount()
.then((value) => print("Unread chats count : " + value.toString()))
.catchError((e, s) => print("Error."));
copied to clipboard
Total unread message count #
Simply call the following function:
ApplozicFlutter.getTotalUnreadCount()
.then((value) => print("Total unread count : " + value.toString()))
.catchError((e, s) => print("Error."));
copied to clipboard
Add contacts #
Add contacts to applozic as below:
dynamic user1 = {
'userId': "user1",
'displayName': "User 1",
"metadata": {
'plugin': "Flutter",
'platform': "Android"
}
};
dynamic user2 = {
'userId': "user2",
'displayName': "User 2",
"metadata": {
'plugin': "Flutter",
'platform': "Android"
}
};
ApplozicFlutter.addContacts([user1, user2])
.then((value) => print("Contact added successfully: " + value))
.catchError((e, s) => print("Failed to add contacts: " + e.toString()));
copied to clipboard
Logout #
Logout from applozic as below:
ApplozicFlutter.logout()
.then((value) =>
print("Logout successfull")
.catchError((error, stack) =>
print("Logout failed : " + error.toString()));
copied to clipboard
Sample app #
You can checkout Applozic Flutter sample app that demonstrates the use of this plugin.
In case of any queries regarding this plugin, write to us at support@applozic.com.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.