Introduction to WebRTC with Temasys Skylink
WebRTC requires you to do significant work around solving signaling issues and resolving differences in implementation between platforms. We, at Temasys, are part of the WebRTC working group at the W3C, and create solutions with and around WebRTC. We know this part of the puzzle inside and out, and that is why we have created Temasys Skylink. We want to solve the connectivity and implementation headaches for you and let you focus on building the cool stuff.
Temasys SkylinkSDK for iOS is part of the Temasys Skylink suite of products, that enables you to easily connect your iPhone, iPod touch or iPad apps with each other and exchange audio, video, messages and files the fastest way possible. Based on WebRTC, it even allows you to connect to users on the web and on Android. Cool, eh?
This article discusses how to get started with the Temasys SkylinkSDK for iOS step by step, and where to go from there.
Visit the Temasys Skylink platform website for additional details: skylink.io
When you use Temasys SkylinkJS in your website or app, you can invite users (we call them peers) to join a shared space in which they can exchange data privately with each other. We call this space a room. Every peer that wants to join a room needs to know its’ unique identifier, like a secure, generated token or a simple name. We leave it up to you on how you come up with these room IDs and how you inform peers about them. One of our primary goals in Teamsys SkylinkJS was to not interfere with your application logic or UX. We recommend generating UUIDs as a best-practice here, for making the identifiers difficult to guess, reasonably unique and providing an additional layer of privacy of your users during room sessions.
In order to start using the Temasys Skylink, you would need to create an Application folder using our Developer Console or REST API. Every application creates a new realm in which your rooms can exist. You can now create unique App Keys under the application you have created. These keys are then used to help you identify yourself to the Temasys Skylink Infrastructure. Every App key for the Web platform will only work on your specified CORS domain name. If you want to have different websites or applications on different platforms(such as android/ios) to access the same realm and therefore the same rooms, you can create multiple keys under the same application – one for each platform. This extends the scope of the realm to other domain or applications.
Read more about creating a new application with our new console here.
#2 Get an App Key
In order start building with our Temasys Skylink platform, you need to get an App Key. Register for an account here.
You can then create and configure App Keys that you will later need to add in your code to connect to our platform.
Setting up a new Xcode project workspace
These are the simple steps to get set up with an empty Xcode project.The SDK is recommended to be installed via cocoapods, if you don’t have it installed follow these steps:
- Check that you have Xcode command line tools installed (Xcode > Preferences > Locations > Command line tools). If not, open the terminal and run
xcode-select --install(more details here if needed).
- Install cocoa pods in the terminal:
$ sudo gem install cocoapodsCocoapods website: cocoapods.org.
- Create new Xcode project
- Close Xcode (.xcodeproj file)
Installation of Temasys SkylinkSDK
pod initin the terminal, where the .xcodeprojfile file is located. This will create the podfile.
pod "SKYLINK"to your pod file, for the appropriate(s) target(s).
pod install. And wait for the terminal to output something like
Pod installation complete! There is 1 dependency from the Podfile and 3 total pods installed
- Open the .xcworkspace file and always work with this from now on (instead of the .xcodeproj file).
- For each target planned to use Temasys SkylinkSDK, go to Build settings (make sure “all” is selected) > Build Options > Enable bit code and set it to NO. This will avoid the “…does not contain bitcode” message
- If you get the error “The resource could not be loaded because the App Transport Security policy requires the use of a secure connection”, edit your info.plist by adding an NSAppTransportSecurity key as Dictionary, and add a sub-key named NSAllowsArbitraryLoads as boolean set to YES.
- Optionally, if you want your app to be able to process audio even when the users leaves the app or locks the device, just enable the VoIP background capability or the audio background capability in the target’s “capabilities” tab.
Understanding the Temasys SkylinkSDK for iOS
The main idea is to prepare and create a connection to a room via the Temasys Skylink platform. After that, you will be able to send messages to the connection and implement the desired protocols to control what happens between the local device and the peers.
Refer to Temasys Skylink API Documentation and the sample application for additional details
Temasys SkylinkSDK for iOS provides 3 classes:
- SKYLINKConnection – the main class, the one you will be sending messages to
- SKYLINKConnectionConfig – to configure the SKYLINKConnection instance before you connect to a room
- SKYLINKPeerMediaProperties – used in delegates methods to get more information about the peers
Here is an example connection code:
Create, configure and set the delegates for a new connection// Creating configuration SKYLINKConnectionConfig *config = [SKYLINKConnectionConfig new]; config.video = YES; config.audio = YES; // Creating SKYLINKConnection self.skylinkConnection = [[SKYLINKConnection alloc] initWithConfig:config appKey:self.skylinkApiKey]; self.skylinkConnection.lifeCycleDelegate = self; self.skylinkConnection.mediaDelegate = self; self.skylinkConnection.remotePeerDelegate = self; // Connecting to a room [self.skylinkConnection connectToRoomWithSecret:self.skylinkApiSecret roomName:ROOM_NAME userInfo:nil];
The common next step is to implement protocols, Temasys SkylinkSDK for iOS provides 7 protocols:
The SKYLINKConnectionLifeCycleDelegate and the SKYLINKConnectionRemotePeerDelegate are the most important. These will give you general details about the lifecycle and the peers that are joining and leaving your application.It is advised to implement them for all applications.
MediaDelegates are implemented if you are using the Temasys SkylinkSDK for simply adding video/voice communication capabilities. Similarly, message delegates and file transfer delegates can be implemented based on whether you require messaging and data transfer capabilities for your application – you get the idea!
That’s about it. We can’t wait to see what you’ll create with our technology! Before you go playing with our SDK, on Xcode, let me just give you important some links.
- Check the documentation on skylink.io/ios.
- Have a look at the iOS Sample App and its readme on Github. It provides simple example ways to build video calls, multi-party video calls, audio calls, chat rooms and file transfer rooms.
- If you encounter any issues or have any enquiries regarding Temasys Skylink, drop us a note on our support portal and we would be happy to help!
This document was edited for Temasys SkylinkSDK for iOS version 1.1.0