iOS client SDK

The Sending.Network iOS SDK provides a messaging framework that enables you to integrate chatroom and notification services within your mobile applications. This quickstart will show you how to set up the SDK and make API calls like user registration, room creation, etc. Let's explore how we would make a simple client that can send and receive messages, create a chat room, get member lists, etc.

Prerequisites

Components
Requirements

OS

iOS 14 or above

Software

Installation

CocoaPods based Installation

You can connect to SDN network by running a local P2P service or connecting to an existing Edge Node.

To build the application that connects to an existing Edge Node, add the following line to the podfile.

pod SendingnetworkSDK/Lite

Include the header

import SendingnetworkSDK

Start the local P2P service

If you connect to an existing edge node in the previous step, you can safely skip this step. To create a local P2P service:

RadixService.shared.start()

Initialize the client

If you choose to connect to an existing Edge Node in the previous step, please contact developer@sending.network for a test node URL and assign it tocredentials.homeserver.

Login in to user DID

Keeping your access token safe is essential, as it allows complete access to your account.

Log in with your access token

Instantiate a new client object and use the access token to log in:

Sync and listen

Next, we start the client which sets up the connection to the server and performs the first sync, then listen for the response to get the latest state from the server:

If you are only interested in some specific type of event, you can set the value of the parameter types:

Create a private room and chat with a user

If you want to chat with a user, you can create a private room.

Create a room

Now you can create a room to chat with a specific interest group.

Invite users with the same interest

It's time to invite users to the room you created.

Get messages of a room

To get messages, we need to reuse the mxSession instance created before:

Post a message to a room

To post a message, we create a content message and specify a room.

Last updated