Overview
In this guide you learn how to add the Client SDK to your iOS app.
Prerequisites
To use the Vonage SDK for iOS, you need to have the following installed:
- Xcode 10 or later
- iOS 10.2 or later
Add the SDK to your iOS Project
Open Xcode with your iOS project.
You can either install the Client SDK directly, or via CocoaPods.
CocoaPods
Open your project's
PodFile. If you don't have one already, open a terminal and run the following commands:Where
Project Diris the path to the parent directory of thePodFile.Under your target add the
NexmoClientpod. ReplaceTargetNamewith your actual target name.Make sure the pod file has the public CocoaPod specs repository source.
Install the Pod by opening a terminal and running the following command:
Where
Project Diris the path to the parent directory of thePodFile.Open the
xcworkspacewith Xcode and disablebitcodefor your target.In your code, import the
NexmoClientlibrary:
Add permissions
To use the in-app voice features, you need to add audio permissions:
In your
Info.plistadd a new row with 'Privacy - Microphone Usage Description' and a description for using the microphone. For example,Audio Calls.In your code add a request for Audio Permissions:
AppDelegate is the best place to do this.
Using client in your app
Login
Create a NXMClient object and login with a jwt user token. If necessary, you can read more about generating the JWT.
Note that `self` should implement the `NXMClientDelegate` protocol.
Connection status
On a successful login, the following delegate method is called with NXMConnectionStatusConnected:
You can check if the connection status is connected with isConnected:
isConnected will be the last connection status of the client if your app is suspended in the background. Therefore the value for isConnected can be stale.
Get current user info
After the login succeeds, the logged in user will be available via:
Conclusion
You added the Client SDK to your iOS app, and logged in to a NXMClient instance. You can now use the NXMClient client in your app, and use the Client SDK functionality.
See also
- Data Center Configuration - this is an advanced optional configuration you can carry out after adding the SDK to your application.