Chat APIs and In-app Messaging SDKs for Developers, by Developers

Applozic powers multi-platform Chat APIs and in-app Messaging SDKs for Android, iOS and the Web that will enable you to build advanced in-app chat solutions your users will love.

Integrate chat in your application with completely customizable UI kits, powerful messaging APIs and SDKs, developed with exceptional security measures in mind.

Documentation    API Explorer

Create Contact

We provide convenient APIs for building your own contact.

  • To create and add a new contact, first create an ALContact object and set the details:
ALContact *contact  = [[ALContact alloc] init];              
contact.userId      = @"adarshk";      // Unique Id for user               
contact.fullName    = @"Adarsh Kumar"; // Fullname of the contact.  
contact.displayName = @"Adarsh";       // Name on display
var contact  = ALContact()              
contact.userId = @"adarshk";      // Unique Id for user               
contact.fullName = @"Adarsh Kumar"; // Fullname of the contact.  
contact.displayName = @"Adarsh";       // Name on display

Add a new contact:

ALContactService * alContactService = [[ALContactService alloc] init];           
[alContactService addContact:contact];
let alContactService = ALContactService()
alContactService.add(contact)

To add a list of contacts:

ALContactService * alContactService = [[ALContactService alloc] init];           
[alContactService addListOfContacts:contacts];
let contactService = ALContactService()
contactService.addList(ofContacts: contacts)

To get a contact object from the local database you need to pass the userId to get the contact

ALContactService * contactService=[[ALContactService alloc] init];
  ALContact *contact =[contactService loadContactByKey:@"userId" value:userId];
let contactService = ALContactService()
let contcat =   contactService.loadContact(byKey: "userId", value: userId)

Show all Contacts

To show all contacts on the list you can use below setting and remember to set this in ALDefaultChatViewSettings method in ALChatManager:

[ALApplozicSettings setFilterContactsStatus:YES];

[ALApplozicSettings setFilterContactsStatus:NO]; // Only contacts you have communicated with will be visible in the contact list
ALApplozicSettings.setFilterContactsStatus(true)

ALApplozicSettings.setFilterContactsStatus(false) // Only contacts you have communicated with will be visible in the contact list

Get Contact Details

You can fetch the contact details using the userId of the user. It returns an ALContact object. This can be used to get user's last seen time or other details like display name, image URL etc.

ALUserService *userService = [[ALUserService alloc] init];
[userService getUserDetail:@"userId" withCompletion:^(ALContact *contact) {
  
    // if the user is online or offline
    NSLog(contact.connected);

    // User's last seen status
    NSLog(contact.lastSeenAt);
}
ALUserService().getUserDetail("userId", withCompletion: {
    contact in
  
    // if the user is online or offline
    print(contact?.connected)

    // User's last seen status
    print(contact?.lastSeenAt)
})

Categorize Contacts

Categorizing contacts is one of the ways we support where groups can be created based on common interests or activities. Follow the steps mentioned below to group contacts together and show the users contacts from a particular group.

  • First, create a group with the contacts you want in that group:
NSMutableArray * memberArray = [NSMutableArray new];
[memberArray addObject:@"firstContact"]; //pass the UserId of user whom you want to add into the contacts group
[memberArray addObject:@"secondContact"];
NSString * contactsGroupId = @"organization1"; //contactsGroupId can be a unique id, it can be be an organization id, event id or any

[ALChannelService addMemberToContactGroupOfType:contactsGroupId withMembers:memberArray withGroupType:CONTACT_GROUP withCompletion:^(ALAPIResponse *response, NSError *error) {

    if(error ){
        NSLog(@"Error while adding user %@",error);
        return ;
    }

    if (response && [@"success" isEqualToString:response.status]) {
        NSLog(@"User added to contacts group");
    }else{
        NSLog(@"User not able to add to contacts group");
    }
}];
let membersArray: NSMutableArray = ["firstContact", "secondContact"]
let contactsGroupId = "organization"
ALChannelService.addMember(toContactGroupOfType: contactsGroupId, withMembers: membersArray, withGroupType: Int16(CONTACT_GROUP.rawValue), withCompletion: { responseReceived, error in
    guard error == nil else {
        NSLog("Error while adding user: %@", error.debugDescription)
        return
    }
    if let response = responseReceived, response.description == "Success" {
        NSLog("Added successfully")
    }
})
  • Now enable the contacts group option and set the groups you want to show:
[ALApplozicSettings enableOrDisableContactsGroup:YES];

NSArray * contactIdList = @[@"organization1", @"organization2"];
[ALApplozicSettings setContactGroupIdList:contactIdList];
ALApplozicSettings.enableOrDisableContactsGroup(true)
ALApplozicSettings.setContactGroupIdList(["organization1", "organization2"])

Build your UI from scratch - User

This will guide you on the user API methods

❗️

Set up ApplozicClient

Note: You need to setup ApplozicClient before using the methods refer to this link

Block user

Use the below method to block the user in one to one chat. It requires receiver userId to be passed for blocking the user.

[applozicClient blockUserWithUserId:@"<RECEIVER-USERID>" withCompletion:^(NSError *error, BOOL userBlock) {
        if(error == nil && userBlock){
            NSLog(@"User is blocked");
        }else{
           NSLog(@"Got some error while blocking ");
        }
    }];
applozicClient.blockUser(withUserId:"<RECEIVER-USERID>") { (error , userBlock) in
            if (error == nil && userBlock ){
                print("User is blocked");
            }else{
                print("Got some issue while blocking ");
            }

        }

This is the argument the above method accepts

Unblock user

Use the below method to unblock the user in one to one chat. It requires receiver userId to be passed for unblocking the user.

[applozicClient unBlockUserWithUserId:@"<RECEIVER-USERID>" withCompletion:^(NSError *error, BOOL userUnblock) {

        if(error == nil && userBlock){
            NSLog(@"User is unblocked");
        }else{
           NSLog(@"Got some error while unblocking ");
        }
    }];
applozicClient.unBlockUser(withUserId: "<RECEIVER-USERID>") { (error, unblock) in
            if (error == nil && unblock ){
                print("user is unblocked");
            }else{
                print("got some issue while unblocking ");
            }
        }

Argument

Type

Description

Argument type

userId

NSString or String

Pass the receiver userId

Required

Updated 6 days ago


What's Next

Message API

Contacts


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.