PortSIP VoIP SDK Manual for iOS  16.2
PortSIP features our newest, supported, quality-assured VoIP SDK used by Several hundred companies around the world for easy VoIP application develop and quality-assured code.
Functions
Initialize and register functions

Functions

(int) - PortSIPSDK::initialize:localIP:localSIPPort:loglevel:logPath:maxLine:agent:audioDeviceLayer:videoDeviceLayer:TLSCertificatesRootPath:TLSCipherList:verifyTLSCertificate:
 Initialize the SDK. More...
 
(int) - PortSIPSDK::setInstanceId:
 Set the instance Id, the outbound instanceId((RFC5626) ) used in contact headers. More...
 
(void) - PortSIPSDK::unInitialize
 Un-initialize the SDK and release resources.
 
(int) - PortSIPSDK::setUser:displayName:authName:password:userDomain:SIPServer:SIPServerPort:STUNServer:STUNServerPort:outboundServer:outboundServerPort:
 Set user account info. More...
 
(void) - PortSIPSDK::removeUser
 Remove user account info.
 
(int) - PortSIPSDK::registerServer:retryTimes:
 Register to SIP proxy server (login to server) More...
 
(int) - PortSIPSDK::refreshRegistration:
 Refresh the registration manually after successfully registered. More...
 
(int) - PortSIPSDK::unRegisterServer
 Un-register from the SIP proxy server. More...
 
(int) - PortSIPSDK::setLicenseKey:
 Set the license key. It must be called before setUser function. More...
 

Detailed Description

Initialize and register functions

Function Documentation

◆ initialize:localIP:localSIPPort:loglevel:logPath:maxLine:agent:audioDeviceLayer:videoDeviceLayer:TLSCertificatesRootPath:TLSCipherList:verifyTLSCertificate:()

- (int) initialize: (TRANSPORT_TYPE)  transport
localIP: (NSString *)  localIP
localSIPPort: (int)  localSIPPort
loglevel: (PORTSIP_LOG_LEVEL)  logLevel
logPath: (NSString *)  logFilePath
maxLine: (int)  maxCallLines
agent: (NSString *)  sipAgent
audioDeviceLayer: (int)  audioDeviceLayer
videoDeviceLayer: (int)  videoDeviceLayer
TLSCertificatesRootPath: (NSString *)  TLSCertificatesRootPath
TLSCipherList: (NSString *)  TLSCipherList
verifyTLSCertificate: (BOOL)  verifyTLSCertificate 

Initialize the SDK.

Parameters
transportTransport for SIP signaling. TRANSPORT_PERS_UDP/TRANSPORT_PERS_TCP is the PortSIP private transport for anti SIP blocking. It must be used with PERS Server.
localIPThe local computer IP address to be bounded (for example: 192.168.1.108). It will be used for sending and receiving SIP messages and RTP packets. If this IP is transferred in IPv6 format, the SDK will use IPv6.
If you want the SDK to choose correct network interface (IP) automatically, please pass the "0.0.0.0"(for IPv4) or "::" (for IPv6).
localSIPPortThe SIP message transport listener port (for example: 5060).
logLevelSet the application log level. The SDK will generate "PortSIP_Log_datatime.log" file if the log enabled.
logFilePathThe log file path. The path (folder) MUST be existent.
maxCallLinesTheoretically, unlimited lines are supported depending on the device capability. For SIP client recommended value ranges 1 - 100.
sipAgentThe User-Agent header to be inserted in SIP messages.
audioDeviceLayer0 = Use OS default device 1 = Set to 1 to use the virtual audio device if the no sound device installed.
videoDeviceLayer0 = Use OS default device 1 = Set to 1 to use the virtual video device if no camera installed.
TLSCertificatesRootPathSpecify the TLS certificate path, from which the SDK will load the certificates automatically. Note: On Windows, this path will be ignored, and SDK will read the certificates from Windows certificates stored area instead.
TLSCipherListSpecify the TLS cipher list. This parameter is usually passed as empty so that the SDK will offer all available ciphers.
verifyTLSCertificateIndicate if SDK will verify the TLS certificate. By setting to false, the SDK will not verify the validity of TLS certificate.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ setInstanceId:()

- (int) setInstanceId: (NSString *)  instanceId

Set the instance Id, the outbound instanceId((RFC5626) ) used in contact headers.

Parameters
instanceIdThe SIP instance ID. If this function is not called, the SDK will generate an instance ID automatically. The instance ID MUST be unique on the same device (device ID or IMEI ID is recommended). Recommend to call this function to set the ID on Android devices.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ setUser:displayName:authName:password:userDomain:SIPServer:SIPServerPort:STUNServer:STUNServerPort:outboundServer:outboundServerPort:()

- (int) setUser: (NSString *)  userName
displayName: (NSString *)  displayName
authName: (NSString *)  authName
password: (NSString *)  password
userDomain: (NSString *)  userDomain
SIPServer: (NSString *)  sipServer
SIPServerPort: (int)  sipServerPort
STUNServer: (NSString *)  stunServer
STUNServerPort: (int)  stunServerPort
outboundServer: (NSString *)  outboundServer
outboundServerPort: (int)  outboundServerPort 

Set user account info.

Parameters
userNameAccount (username) of the SIP. It's usually provided by an IP-Telephony service provider.
displayNameThe display name of user. You can set it as your like, such as "James Kend". It's optional.
authNameAuthorization user name (usually equal to the username).
passwordThe password of user. It's optional.
userDomainUser domain. This parameter is optional. It allows to pass an empty string if you are not using domain.
sipServerSIP proxy server IP or domain. For example: xx.xxx.xx.x or sip.xxx.com.
sipServerPortPort of the SIP proxy server. For example: 5060.
stunServerStun server, used for NAT traversal. It's optional and can pass an empty string to disable STUN.
stunServerPortSTUN server port. It will be ignored if the outboundServer is empty.
outboundServerOutbound proxy server. For example: sip.domain.com. It's optional and allows to pass an empty string if not using outbound server.
outboundServerPortOutbound proxy server port. It will be ignored if the outboundServer is empty.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ registerServer:retryTimes:()

- (int) registerServer: (int)  expires
retryTimes: (int)  retryTimes 

Register to SIP proxy server (login to server)

Parameters
expiresRegistration refreshment interval in seconds. Maximum of 3600 allowed. It will be inserted into SIP REGISTER message headers.
retryTimesThe retry times if failed to refresh the registration. Once set to <= 0, the retry will be disabled and onRegisterFailure callback triggered for retry failure.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code. If registration to server succeeds, onRegisterSuccess will be triggered, otherwise onRegisterFailure triggered.

◆ refreshRegistration:()

- (int) refreshRegistration: (int)  expires

Refresh the registration manually after successfully registered.

Parameters
expiresRegistration refreshment interval in seconds. Maximum of 3600 supported. It will be inserted into SIP REGISTER message header. If it's set to 0, default value will be used.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code. If registration to server succeeds, onRegisterSuccess will be triggered, otherwise onRegisterFailure triggered.

◆ unRegisterServer()

- (int) unRegisterServer

Un-register from the SIP proxy server.

Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

◆ setLicenseKey:()

- (int) setLicenseKey: (NSString *)  key

Set the license key. It must be called before setUser function.

Parameters
keyThe SDK license key. Please purchase from PortSIP.
Returns
If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.