Skip to content
This is a sample Chat App demonstrates the use of EnableX (https://www.enablex.io) platform Server APIs and iOS Toolkit to build iOS chat application. It allows developers to ramp up on app development by hosting on their own devices.
Objective-C Swift Other
Branch: master
Clone or download
Latest commit 080a47d Dec 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sampleiOS
README.md

README.md

A Sample Chat App with EnableX iOS Toolkit

This is a sample Chat App demonstrates the use of EnableX (https://www.enablex.io) platform Server APIs and iOS Toolkit to build iOS chat application. It allows developers to ramp up on app development by hosting on their own devices.

This App creates a virtual Room on the fly hosted on the Enablex platform using REST calls and uses the Room credentials (i.e. Room Id) to connect to the virtual Room as a mobile client. The same Room credentials can be shared with others to join the same virtual Room to carry out a RTC (Real Time Communication) session.

EnableX Developer Center: https://developer.enablex.io/

1. How to get started

1.1 Pre-Requisites

1.1.1 App Id and App Key

  • Register with EnableX [https://www.enablex.io]
  • Create your Application
  • Get your App ID and App Key delivered to your Email

1.1.2 Sample iOS Client

1.1.3 Sample App Server

1.1.4 Configure iOS Client

  • Open the App
  • Go to VCXConstant.swift and change the following:
 let userName = "USERNAME"  /* HTTP Basic Auth Username of App Server */
 let password = "PASSWORD"  /* HTTP Basic Auth Password of App Server */
 let kBaseURL = "FQDN"      /* FQDN of of App Server */

Note: The distributable comes with demo username and password for the Service.

1.2 Test

1.2.1 Open the App

  • Open the App in your Device. You get a form to enter Credentials i.e. Name & Room Id.
  • You need to create a Room by clicking the "Create Room" button.
  • Once the Room Id is created, you can use it and share with others to connect to the Virtual Room to carry out a RTC Session.

2 Server API

EnableX Server API is a Rest API service meant to be called from Partners' Application Server to provision video enabled meeting rooms. API Access is given to each Application through the assigned App ID and App Key. So, the App ID and App Key are to be used as Username and Password respectively to pass as HTTP Basic Authentication header to access Server API.

For this application, the following Server API calls are used:

To know more about Server API, go to: https://developer.enablex.io/latest/server-api/

3 iOS Toolkit

iOS App to use iOS Toolkit to communicate with EnableX Servers to initiate and manage Real Time Communications.

4 Application Walk-through

4.1 Create Token

We create a Token for a Room Id to get connected to EnableX platform to connect to the Virtual Room to carry out a RTC Session.

To create Token, we make use of Server API. Refer following documentation: https://developer.enablex.io/latest/server-api/rooms-route/#create-token

4.2 Connect to a Room

We use the Token to get connected to the Virtual Room. Once connected with room, user in same room can exchange their message to each other. https://developer.enablex.io/latest/client-api/ios-toolkit/enxrtc/

4.3 Send Data

/* Send Data*/
EnxRoom.sendMessage(text, broadCast: true, clientIds: [])
/* Here user will send chat message to all participents or listed participent's in room

    broadCast = true/false
        To send to all Participants in the room set broadCast = true. Otherwise set it to false to send to a list of Recipients.    
    clientIds = [] 
        Pass a list of recipient clientId. To send to all participants, pass [] or nil as clientId.
*/

/* Example of Delegates */
/* Delegate: didConnect 
Handles successful connection to the Virtual Room */ 

func room(_ room: EnxRoom?, didConnect roomMetadata: [AnyHashable : Any]?) { 
    /* You may initiate and publish your stream here */
} 


/* Delegate: didError
 Error handler when room connection fails */
 
func room(_ room: EnxRoom?, didError reason: String?) { 

} 
/* Delegate: userDidJoined
 To handle any new user added to the Virtual Room */
 
func room(_ room: EnxRoom?, userDidJoined Data: [Any]?) {
  //Handle new user connected in the room
} 

/* Delegate: userDidDisconnected
 To handle any user left from Virtual Room */
  
func room(_ room: EnxRoom?, userDidDisconnected Data: [Any]?) {
    //Handle new user disconnected from the room
}
/* Delegate: didReceiveChatDataAtRoom
To handle any chat recieve at room */
 func room(_ room: EnxRoom, didReceiveChatDataAtRoom data: [Any]?) {
    /* Handle chat UI here */
}
You can’t perform that action at this time.