This repository contains the WatchRTC_SDK iOS binaries.
The SDK is geared towards those who want to collect WebRTC related data from an iOS app, log and analyze it as part of the testRTC environment.
- iOS version >= 13.0
- Right click on your project’s name and choose “Add Packages”:
- On the new window that opened, paste the following url into the search bar on the right side: https://github.com/testRTC/watchRTCSDK-iOS
- Set the “Dependency Rule” to
Up to Next Major
and specify the version you need:
- Click “Add Package”, wait for the installation to finish and click “Add Package” again.
- The WatchRTC_SDK library is now added to your project.
It automatically appears in the left pane under “Package Dependencies”:
Check out Get Started tab on cocoapods.org. To use WatchRTC_SDK in your project add the following line to your 'Podfile':
pod 'WatchRTC_SDK'
Then, in Terminal, run:
pod install
In order to update the SDK to the newest version, in Terminal, run:
pod update WatchRTC_SDK
- Download the latest version of
WatchRTC_SDK.xcframework
. It can be done either by downloading a zip archive from the tags page or by cloning this repository with a git client. - Open your Xcode project and click on project's name in "Project Navigator".
- Click on your app target to open your target's "General" settings tab:
- Scroll down to the "Frameworks, Libraries, and Embedded Content" section.
- Drag and drop
WatchRTC_SDK.xcframework
onto the "Frameworks, Libraries, and Embedded Content" section. - Ensure that "Embed & Sign" is selected:
The below code should be added to the top of a source file of your application, where you would like to use the SDK.
import WatchRTC_SDK
In order to provide statistics data to WatchRTC, your application should implement the RtcDataProvider
protocol. The protocol should be implemented somewhere in your application where you have access to the WebRTC's peerConnection
object.
extension WebRTCClient: RtcDataProvider {
func getStats(callback: @escaping (RTCStatsReport) -> Void) {
// get stats report from peerConnection (or another source if you are not using WebRTC directly)
// and call callback(stats)
}
}
The WatchRTCConfig
object must be initialized with your API KEY, ROOM ID, and PEER ID. The rest is optional.
let config = WatchRTCConfig(
rtcApiKey: "<your_api_key>",
rtcRoomId: "room_id",
rtcPeerId: "peer_id",
keys: "optional keys dictionary"
)
// Optionally - pass config to the constructor
let watchRTC = WatchRTC(rtcDataProvider)
You must keep the watchRTC
object in memory as long as you want to be connected to the testRTC's servers.
watchRTC.setConfig(config)
// Call connect() when a peer connection is active.
// The method can throw, so be sure to enclose it in do-try-catch statement.
do {
try watchRtc?.connect()
} catch {
debugPrint(error)
}
From this point, you can see your session on the WatchRTC dashboard.
In order to close your connection to testRTC's servers, you need to call disconnect()
// Should be called once the WebRTC's peerConnection is closed.
watchRtc?.disconnect()
For the detailed API documentation WatchRTC_SDK.doccarchive (Can be opened with Xcode)
For more details on how to use the SDK, see the
- WebRTC Sample app - shows how to integrate WatchRTC SDK into applications working with WebRTC directly.
- Twilio Sample app - shows how to integrate WatchRTC SDK into applications working with Twilio SDK.
- Vonage Sample app - shows how to integrate WatchRTC SDK into applications working with Vonage SDK (formerly TokBox OpenTok).