Chat APIs and In-app Messaging SDKs for Developers

Applozic provides Chat APIs and In-app Messaging SDKs for Android, iOS and Web apps to power cross-device, multi-platform rich messaging.
Find comprehensive guides and platform-specific Chat API documentation to get started with In-app Messaging.

Guides    API Explorer

iOS Custom UI Quickstart

A quick start guide for creating your own UI using Custom UI APIs present in the Applozic iOS SDK. Using custom UI APIs, you can implement your own designs with your custom workflows.

In just three steps, we'll go from framework installation to sending a message.

1. Installation

The first step is installing the Applozic framework.
There are different ways to do it. Check out the detailed steps for installation here. Our preferred way of installation is Cocoapods.

If you install using CocoaPods then just add the below code in apps podfile and run pod install.

target 'MyTargetName' do
    use_frameworks!
    pod 'Applozic'
end

2. Authentication

Before sending a message, we need to authenticate the user. It's a two-step process:

First, initialise the SDK with the App ID as shown below. For more details check out the Setup section. Your App ID can be found here---> App ID

#import <Applozic/Applozic.h>


@property (strong, nonatomic) ApplozicClient *applozicClient;
// Call it only once in your app.
self.applozicClient = [[ApplozicClient alloc]initWithApplicationKey:@"<APP_ID>" withDelegate:self]; // Replace this with your App ID
import Applozic
  
var  applozicClient = ApplozicClient()

// Call it only once in your app.
applozicClient = ApplozicClient(applicationKey: "applozic-sample-app", with: self) as ApplozicClient // Replace this with your App ID

The second step is to register the user as shown below. For more details check out the Registration section. Here a unique user Id will be used for each user.

ALUser *user = [[ALUser alloc] init];
user.userId = @"userId";
user.password = @"password";
user.displayName = @"displayName";
user.imageLink = @"imageUrlLink";
user.authenticationTypeId = APPLOZIC;

[self.applozicClient loginUser:user withCompletion:^(ALRegistrationResponse *response, NSError *error) {
    if(!error){
        NSLog(@"Login success");
    }
}];
let user = ALUser()
user.userId = "userid" //pass the login userId
user.password = "password" //pass the password
user.imageLink = ""  // User's profile image link.
user.displayName = "DemoUserName" // User's Display Name   
ALUserDefaultsHandler.setUserAuthenticationTypeId(Int16(APPLOZIC.rawValue))

applozicClient.loginUser(user, withCompletion: { response, error in
     if error == nil {
          print("Login success")
     }
 })

3. Send a Message

The logged in user can send a message to another user or in a group. In this guide, we will see how it works in case of sending a message to another user. For a detailed explanation check out Message API section.

It's a single call where we need to pass the userId and the message that we need to send. As we are just trying out the APIs, we can send a message to a test user, in your app first you will have to register the user to whom you want to send a message and you can show them as a list of contacts to the sender. Check the Contacts section to learn more about creating and fetching contacts.

// Message builder
ALMessage *alMessage = [ALMessage build:^(ALMessageBuilder * alMessageBuilder) {
        alMessageBuilder.to = @"testId"; //Replace this later message
        alMessageBuilder.message = "Test message";    
}];
    
// Pass an `ALMessage` object to this method.
[self.applozicClient sendTextMessage:alMessage withCompletion:
 ^(ALMessage *message, NSError *error) {
        
    if(!error){
        NSLog("Success: Message sent 🎉");
    }       
}];
// Message builder
let alMessage = ALMessage.build({ alMessageBuilder in
 
        guard let messageBuilder = alMessageBuilder else { return }
        messageBuilder.to = "testId" //Replace this later
        messageBuilder.message = "Test message"
})

// Pass an `ALMessage` object to this method.
applozicClient.sendTextMessage(alMessage, withCompletion: { (alMessage, error) in       
    if(error == nil){
        print("Success: Message sent 🎉")
    }
})

Run the above code to test if the message is sent. In case of an error, the error param will have the error details.

Here's a list of some other relevant sections that you might need:

  • For fetching a list of conversations: Conversation section.
  • To get Real-time updates on a message received, read or if the other user is typing: Real-time updates section. In this section, we have also explained how to send typing status if the logged in user is typing. To receive app notifications Push notification setup is required.
  • To update user details like display name, image etc. after the user has been registered check out Update user details section.
  • For creating a group, adding users and updating the group details check out Groups section.

Sample App

You can check out the sample app where we have used iOS Custom UI APIs to show some of the SDK features.

👍

Support

If you have any doubts or you are facing any issue in integration then you can check out our support page for help.

Updated 2 years ago


iOS Custom UI Quickstart


Suggested Edits are limited on API Reference Pages

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