iOS
Introduction to Zoiper SDK 2.0 for iOS
Developing your VoIP application for iOS with Objective-C™, or Swift becomes easier with the Zoiper Software Development Kit for iOS. Zoiper SDK 2.0 is namely an all-inclusive solution for developing iOS applications with:
- audio calls (SIP, IAX)
- video call (SIP)
- presence
- messaging
- call recordings
- other functionalities
The SDK consists of an iOS Framework with the respective headers that you can easily integrate into your target application.
Hardware and software requirements
Requirement | Description |
---|---|
Processor | Intel Core i3 or better |
Memory | 4GB (minimum), 8 GB (recommended) |
Hard disk space | 1 GB |
Xcode® | Xcode 12 or later |
Operating system (Development environment) | macOS 10.15 or later |
Operating system (Runtime environment) | iOS 12 or later |
Architecture | arm64 |
Mode | Live device |
Contents of the SDK package
Folder | Description |
---|---|
package/Documentation | Contains the Zoiper SDK 2.0 Documentation. Click on the index.html file to open the documentation in your browser. |
package/zdk.objc.framework | The actual framework which you need to import in your project. |
Setting up the Demo project
The demo application for Swift — Zoiper SDK Demo — gives you a clear idea on how to implement functionalities of the Zoiper Software Development Kit for iOS. After the initialization of the Zoiper SDK 2.0 Demo, you can configure and register an account on a SIP server. Upon success, you can make an audio call. The Demo illustrates how...
- to implement the SDK into a real project
- to connect the development kit with your project
- the main functionalities are used
- callbacks are handled
- SDK logging takes place
We assume that you are already familiar with iOS and Objective-C concepts such as:
- delegates
- Objective-C memory management
- Cocoa’s Storyboard for the UI elements of the demo app
Since the purpose of the demo is to illustrate the main functionalities of the Zoiper SDK 2.0, the UI is limited.
Prerequisites
To compile the Demo project, you must have all of the following:
- an Apple developer account
- a developer-registered iOS device
- XCode
- a SIP server to test with
- a SIP account corresponding to the SIP Server
- a license for the Zoiper SDK 2.0 and the activation details.
Setting up the project files
- Download the Zoiper SDK 2.0 Demo
- Open the xcodeproj file with XCode.
- Connect a registered iOS device and select it as a building target.
- Click the Run button to build the sample app for the device.
- When the application runs enter the Activation details to activate the product.
To be able to run the Zoiper Swift Example, you will need to include the zdk.objc.framework to the project and then to build it. By default zdk.objc.framework is not included in the example. If you still don't have the framework, please contact us on zoiper.com.
zdk.objc.framework MUST be placed in current folder!
Default configuration
Transport type: TCP Enabled codecs:
- aLaw
- uLaw
- GSM
- speex
- iLBC
- G729
- VP8
STUN: Disabled
Default STUN settings:
- Server: stun.zoiper.com
- Port: 3478
- Refresh period: 30000
Activation
To test the demo, you need activation credentials from Zoiper. You can enter them manually, or hardcode them in your application.
Manual
Enter your username and password in the Activation fields and click on the “Activate” button.
When the activation is fine, the status will change to “Success”. If it is not successful a “Failed” status will be returned, followed by an error code.
Hardcoded
To hardcode your credentials, use the following call:
let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.contextManager.activateZDK(zdkVersion,
withUserName: activationUsername!.text!,
andPassword: activationPassword!.text!)
Do not take your credentials from the GUI, but pass them.
Account registration
You need a SIP account to register to the server and make calls. To configure it, follow these steps:
- Enter its details (username, password and hostname at least)
- Click on the „Register“ button
The status screen will show a registration status. When the registration is successful you should be able to make calls. In the other case, the status screen will show an error code.
Changing the account configuration
To change the SIP configuration, you will need to adjust the calls in:
private func createDefaultSIPConfiguration() -> ZDKSIPConfig
You can adjust the configuration by using the following method calls.
Transport type
sipConfiguration.transport = .tt_TCP
Possible values:
- .tt_TCP
- .tt_UDP
- .tt_TLS
Outbound proxy
sipConfiguration.useOutboundProxy = false
sipConfiguration.outboundProxy = nil
sipConfiguration.authUsername = nil
STUN
sipConfiguration.stun = createDefaultSTUNConfiguration()
Rport
sipConfiguration.rPort = .rpt_Signaling
DTMF
sipConfiguration.dtmf = .dtmftsip_RFC_2833
Possible values:
- .dtmfsip_RFC_2833
- .dtmfsip_SIPInfo
- .dtmfsip_inband
- disabled
Push notifications
To change the PUSH configuration, you will need to adjust the calls in:
private func createDefaultPushConfiguration() -> ZDKPushConfig
You can adjust the push configuration by using the following method calls.
Sets the use of push notifications
pushConfiguration.enabled = false
Sets the use of RTP media proxy
pushConfiguration.rtpMediaProxy = false
Application - Proxy communication protocol
pushConfiguration.transport = .tt_TCP
Application's bundle identifier
pushConfiguration.cid = Bundle.main.bundleIdentifier!
The URI of push apple server
pushConfiguration.uri = "https://gateway.push.apple.com:2195"
Type
pushConfiguration.type = "apple"
Push proxy address
pushConfiguration.proxy = "www.push_proxy.com"
Push token
pushConfiguration.token = "a6954b367dc0d28308a92dff76b7041abf9193e834bafd50cee0222068cb632b"
Header fields
To change the header fields configuration, you will need to adjust the calls in:
private func createSIPHeaderFieldsConfiguration() -> [ZDKHeaderField]
You can adjust the values by using the following method calls.
header1Values.append("header_1_value_1")
header2Values.append("header_2_value_1")
header2Values.append("header_2_value_2")
header3Values.append("header_3_value_1")
header3Values.append("header_3_value_2")
header3Values.append("header_3_value_3")
header4Values.append("header_4_value_1")
header4Values.append("header_4_value_2")
header4Values.append("header_4_value_3")
header4Values.append("header_4_value_4")
header4Values.append("header_4_value_5")
You can adjust the name and set a header by using the following method calls.
headers.append(zdkAccountProvider.createSIPHeaderField("test_header_1", values: header1Values, method: .smt_All))
headers.append(zdkAccountProvider.createSIPHeaderField("test_header_2", values: header2Values, method: .smt_Register))
headers.append(zdkAccountProvider.createSIPHeaderField("test_header_3", values: header3Values, method: .smt_Invite))
headers.append(zdkAccountProvider.createSIPHeaderField("test_header_4", values: header4Values, method: .smt_All))
Possible method values:
Method |
---|
smt_None |
smt_Invite |
smt_Notify |
smt_Options |
smt_Register |
smt_Subscribe |
smt_Message |
smt_Info |
smt_Publish |
smt_Service |
smt_All |
Changing the used codecs
zdkAccount!.mediaCodecs = [CodecId.uLaw.rawValue as NSNumber,
CodecId.aLaw.rawValue as NSNumber,
CodecId.GSM.rawValue as NSNumber,
CodecId.speex.rawValue as NSNumber,
CodecId.iLBC20.rawValue as NSNumber,
CodecId.g729.rawValue as NSNumber,
CodecId.vp8.rawValue as NSNumber]
Possible values and Codec Ids:
Codec |
---|
uLaw |
GSM |
aLaw |
g722 |
g729 |
speex |
speexWide |
speexUltra |
iLBC |
g726 |
vp8 |
opusNarrow |
opusWide |
opusSuper |
opusFull |
Create your iOS VoIP App
You need to set up your environment in the same way as for the demo application. Keep in mind that the application must run on a real device. It cannot be used with simulators.
To use Zoiper SDK 2.0 in your iOS project, you need to add it as a required framework to your project and initialize it as a context. Below, you can see how to initialize the context:
override init() {
zdkContext = HelperFactory.sharedInstance().context
zdkAccountProvider = HelperFactory.sharedInstance().context.accountProvider
super.init()
zdkContext.setStatusListener(self)
initContext()
}
func initContext() {
zdkContext.configuration.sipUdpPort = Int32.random(in: 32000..<65000)
repeat {
zdkContext.configuration.rtpPort = Int32.random(in: 32000..<65000)
} while (zdkContext.configuration.rtpPort != zdkContext.configuration.sipUdpPort)
zdkContext.audioControls.setAutomaticGainControlMode(.agct_Hardware, gain: 0.0)
zdkContext.audioControls.echoCancellation = .ect_Hardware
zdkContext.audioControls.noiseSuppression = true
zdkContext.configuration.enableIPv6 = true
}
Keep in mind that inside the initialization of the Context, the SIP and RTP ports will be also initialized. Right after this, you can best activate the Zoiper SDK 2.0 license. Use the activation username and password you received from Zoiper.com. You can complete the activation by invoking the activateZDK method as follows:
activateZDK method like so:
contextManager.activateZDK(zdkVersion,
withUserName: activationUsername,
andPassword: activationPassword)
iOS SDK Reference - Swift/Objective C
You can find the API and method references here.