flutter.dev has a comprehensive starter tutorial on creating your first application using Flutter. Once you are ready to integrate using the Applozic SDK, follow these steps:
1. Add the following dependency in your pubspec.yaml file:
# other dependencies
2. Install the package as shown below:
flutter pub get
3. Import the applozic_flutter in your .dart file to use the methods from Applozic:
Create an Applozic user object, and pass it to the login() function as shown below:
Please keep in mind that once the user is logged in, a new login is permitted only after the user logs out. Use this code to check if the user is already logged in:
Update logged in user details
You can update the logged in user details as given below:
Get logged in userID
You can get the userID of the logged in user as given below:
III. Push Notifications
- Go to /android/build.gradle
- Add the following under buildscript → dependencies: classpath 'com.google.gms:google-services:4.0.1'
- Add the following at the bottom of the file: apply plugin:'com.google.gms.google-services'
- After adding, it will look something like this:
- From login success callback, call ApplozicFlutter.registerPushNotification();
- For push notifications, you must have a Firebase account: Sign-up to https://console.firebase.google.com/ and create your application and generate push notification services file.
- Download google-services.json from your Firebase Console and paste it to /android folder
- Go to the Applozic console, update the FCM Server Key from the Firebase account to your Applozic account push notification section here.
Launch main chat screen
Launch the main chat screen as below:
Launch Chat with a specific User
Launch the conversation with a user by passing the userID as below:
To send a message to a contact or a group, you must first create a message object:
Note: A message object can have more parameters. Refer to this link:
Then pass the message object to this function:
To log out from Applozic, execute the following code:
In this tutorial, we have implemented basic features of a chat messenger application such as one-to-one messaging and push notifications using Applozic’s powerful Flutter SDK. To add more features like Group Messaging, Audio and Video Call, Rich Messaging, and many more, visit Applozic’s documentation website.