Stringee Widget is the easiest way to quickly add video call to your mobile app. Stringee Widget provides a basic and non-customizable UI to make a video call from the mobile app. To customize your UI and utilize advanced Stringee API features, you need to follow the tutorial here: https://developer.stringee.com/docs/stringeex-api-getting-started-ios-api
This tutorial walks you through the steps of using Stringee Widget.
Before you use Stringee Widget to make or receive a video call, you must sign up for a Stringee account. There're 2 ways to do it:
Sign up a Stringee account on: https://developer.stringee.com/account/register
Go to the Dashboard and Create a project
Create a portal
Generate an access token: Tools -> Generate Access Token
Sign up a StringeeX account on: https://stringeex.com/en/register
Create a portal
Generate an access token: Sign in stringee.com with the StringeeX account then go to Tools -> Generate Access Token
The simplest way to import the SDK into an iOS project is with CocoaPods. Open your project's Podfile and add this line to your app's target:
pod 'StringeeWidget'
Then from the command line run:
pod install --repo-update
If you're new to CocoaPods, see their official documentation for info on how to create and use Podfiles.
In the "Build Settings" tab -> "Other linker flags" add "$(inherited)" flag
In the "Build Settings" tab -> "Enable bitcode" select "NO"
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses Camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses Microphone</string>
In order to connect to Stringee Server, you will need access to the authentication credential: access token. In production application, the access token should be generated by your server described here: Client authentication. But to speed things up, we will just use the access token generated in Step 1 for now:
import StringeeWidget
import Stringee
extension ViewController: StringeeWidgetDelegate {
func onConnectionConnected(userId: String, isReconnecting: Bool) {
print("onConnectionConnected")
}
func onConnectionDisconnected(isReconnecting: Bool) {
print("onConnectionDisconnected")
}
func onConnectionError(code: Int, message: String) {
print("onConnectionError: \(message)")
}
func onRequestNewToken() {
print("onRequestNewToken")
// let newToken = "YOUR_NEW_ACCESS_TOKEN"
// stringeeWidget.connect(token: newToken)
}
func onDisplayCallingViewController(vc: UIViewController) {
// vc.modalPresentationStyle = .fullScreen
// present(vc, animated: true, completion: nil)
}
func onSignalingState(state: SignalingState) {
print("onSignalingState: \(state.rawValue)")
// if state == .ended || state == .busy {
// DispatchQueue.main.async {
// self.dismiss(animated: true, completion: nil)
// }
// }
}
}
let stringeeWidget = StringeeWidget.instance
let accessToken = "YOUR_ACCESS_TOKEN"
override func viewDidLoad() {
super.viewDidLoad()
stringeeWidget.delegate = self
stringeeWidget.connect(token: accessToken)
}
Now you can make a call from your mobile
Initialize a call config:
var callConfig = StringeeCallConfig()
callConfig.from = stringeeWidget.stringeeClient.userId
callConfig.to = "testcall"
callConfig.isVideoCall = true
Make call
stringeeWidget.makeCall(config: callConfig) { status, code, message, customData in
print(message)
}
Monitor the call state: When the client makes a video call successfully, the call will walk through many states such as calling, ringing, answered, ended, busy… Each time the call’s state changes, the onSignalingState() method is invoked.
Now that your code is complete, you can run the app with your device. You can view a completed version of this sample app on GitHub: StringeeWidgetSample