Objective-C

NXMClient

Before you can start a chat, the Client SDK needs to authenticate to the Vonage servers. The following additions are required to ViewController.m.

At the top of the file, import NexmoClient and User.

Add a NXMClient instance and user property below the statusLabel.

Button targets

For the log in buttons to work, you need to add targets to them which will run a function when they are tapped. In the ViewController.m file add the following.

Then link the two functions them to their respective buttons at the end of the viewDidLoad function.

Add the log in function

At the end of ViewController.m, add the login function needed by the setUserAs functions. This function sets the client's delegate and logs in.

The client delegate

For the delegate to work, you need to have ViewController conform to NXMClientDelegate. To do this you will need to add the NXMClientDelegate to the interface definition for ViewController.m.

Then at the end of the file, add the following NXMClientDelegate functions.

An error is shown if encountered and the statusLabel is updated with the relevant connection status.

Build and Run

Press Cmd + R to build and run again. If you tap on one of the log in buttons it will log the client in with the respective user:

Interface connected