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

NOTE: Notice that, you have already imported NexmoClient at the top of the file.

Add a NXMClient instance and conformance to the NXMClientDelegate to the interface .

@interface ViewController () <NXMClientDelegate>
@property UILabel *connectionStatusLabel;
@property NXMClient *client;

Add the JWT

At the end of viewDidLoad, set the client delegate and log in - please make sure to replace ALICE_JWT for the JWT you created during a previous step. Please remember, the expiry time for the token was set to 6 hours so you will need to generate a new one if it is too old.

- (void)viewDidLoad {

    self.client = NXMClient.shared;
    [self.client setDelegate:self];
    [self.client loginWithAuthToken:@"ALICE_JWT"];

The Client Delegate

For the delegate to work, you need to have ViewController conform to NXMClientDelegate. Add these two delegate functions to the class.

- (void)client:(nonnull NXMClient *)client didChangeConnectionStatus:(NXMConnectionStatus)status reason:(NXMConnectionStatusReason)reason {
    dispatch_async(dispatch_get_main_queue(), ^{
        switch (status) {
            case NXMConnectionStatusConnected:
                self.connectionStatusLabel.text = @"Connected";
            case NXMConnectionStatusConnecting:
                self.connectionStatusLabel.text = @"Connecting";
            case NXMConnectionStatusDisconnected:
                self.connectionStatusLabel.text = @"Disconnected";

- (void)client:(nonnull NXMClient *)client didReceiveError:(nonnull NSError *)error {
    dispatch_async(dispatch_get_main_queue(), ^{
        self.connectionStatusLabel.text = error.localizedDescription;

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

Build and Run

Press Cmd + R to build and run again:

Interface connected
Interface connected