CocoaPods trunk is moving to be read-only. Read more on the blog, there are 9 months to go.
Maintained by cicareteam.
| Depends on: | |
| WebRTC-lib | = 138.0.0 |
| Socket.IO-Client-Swift | = 16.1.1 |
| Starscream | = 4.0.8 |
| CryptoSwift | = 1.8.4 |
This SDK allows you to integrate outgoing and incoming call features into your iOS app using CiCare SDK.
Add the CocoaPods source in your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
target 'YourAppTarget' do
use_frameworks!
pod 'CiCareSDKCallIOS', '1.2.1-rc.34'
end
`
Then run:
pod install
Open your Xcode project settings → Signing & Capabilities.
Add the following capabilities:
Push Notifications
Background Modes → Check:
Voice over IPBackground fetchRemote notificationsInfo.plistAdd these keys for proper permission descriptions:
<key>UIBackgroundModes</key>
<array>
<string>voip</string>
<string>fetch</string>
<string>remote-notification</string>
</array>
<key>NSUserNotificationUsageDescription</key>
<string>This app uses notifications to alert you for incoming calls.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires microphone access for voice calls.</string>
Import module:
import CiCareSDKCall
Before starting a call, configure the API:
CicareSdkCall.shared.setAPI(baseUrl: "https://your-api-url.com", token: "your-api-token")
Use the following code to start an outgoing call:
func makeCall() {
CicareSdkCall.shared.outgoing(
callerId: "2",
callerName: "Halis",
callerAvatar: "https://avatar.iran.liara.run/public/boy",
calleeId: "3",
calleeName: "Anas",
calleeAvatar: "https://avatar.iran.liara.run/public",
checkSum: "asdfasdf",
metaData: ["call_title": "Free Call"]
)
}
To display an incoming call, add the following code when handling the VoIP type APNs notification:
CicareSdkCall.shared.incoming(
callerId: "2",
callerName: "Halis",
callerAvatar: "https://avatar.iran.liara.run/public/boy",
calleeId: "3",
calleeName: "Anas",
calleeAvatar: "https://avatar.iran.liara.run/public",
checkSum: "asdfasdf",
metaData: [:]
) {
print("on message button clicked")
}
Note:
metaData["alert_data"]is required.
You can customize call labels or status texts using the metaData parameter.
Example:
let meta: [String: String] = [
"call_title": "Free Call",
"call_busy": "User is busy",
"call_weak_signal": "Weak signal"
]
CicareSdkCall.shared.outgoing(
callerId: "2",
callerName: "Halis",
callerAvatar: "https://avatar.iran.liara.run/public/boy",
calleeId: "3",
calleeName: "Anas",
calleeAvatar: "https://avatar.iran.liara.run/public",
checkSum: "asdfasdf",
metaData: meta
) { result in
}
You can get call state event by doing this
class CallEventDelegate: CallEventListener {
CicareSdkCall.shared.delegate = this
public func onCallStateChanged(_ state: CallStatus) {
print(state)
}
}
State list are:
When you make an outgoign call there are error code result
CicareSdkCall.shared.outgoing(...) { result in
switch result {
case .success:
print("Call success")
case .failure(let error):
print("Error:", error.numericCode, error.localizedDescription)
}
}
Error code list are:
CocoaPods: https://cocoapods.org/pods/CiCareSDKCallIOS
Latest version: 1.2.1-rc.34
Apple Docs:
CicareSdkCall is a singleton, always use CicareSdkCall.shared instead of creating a new instance.