This is the cine.io Peer iOS SDK. This library allows you to integrate real-time live video and audio chat to your iOS application. It is fully compatable with with the cine.io Peer Android SDK and cine.io peer JavaScript SDK.
The easiest way to use the SDK is via CocoaPods. Create a new
XCode project with a file named Podfile
that contains the
following:
pod 'cineio-peer-ios', '0.0.10'
Then, install the Pod by running the pod install
command:
pod install
Then you can open the project using the <project>.xcworkspace
file:
open <project>.xcworkspace
Check out the cineio-peer-ios-example-app repository for a working example that use this SDK.
Start by including the necessary files
#import "CinePeerClient.h"
#import "CinePeerClientConfig.h"
#import "CineCall.h"
#import "CineIdentity.h" // Only necessary if your app requires identifying
#import "RTCMediaStream.h"
#import "RTCEAGLVideoView.h" // For displaying media strems
For simplicity sake, let's make our ViewController
a CinePeerClientDelegate
In ViewController.m
@interface ViewController () <CinePeerClientDelegate>
In ViewController.m
, because that's our CinePeerClientDelegate
.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *CINE_IO_PUBLIC_KEY = @"CINE_IO_PUBLIC_KEY";
NSString *CINE_IO_SECRET_KEY = @"CINE_IO_SECRET_KEY";
// Initialize the CinePeerClientConfig class
// Pass in a CinePeerClientDelegate
CinePeerClientConfig *config = [[CinePeerClientConfig alloc] initWithPublicKey:CINE_IO_PUBLIC_KEY delegate:self];
// Create the peer client
CinePeerClient *cinePeerClient = [[CinePeerClient alloc] initWithConfig:config];
}
You'll add the CinePeerClientDelegate
methods to your ViewController
.
// happens when a new peer joins, or your local camera and microphone starts
- (void) addStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// happens when a peer leaves, or your local camera and microphone stops
- (void) removeStream:(RTCMediaStream *)stream peerConnection:(RTCPeerConnection *)peerConnection local:(BOOL)local;
// when a new call comes in
- (void) handleCall:(CineCall *)call;
// when a call that came to you is cancelled
- (void) onCallCancel:(CineCall *)call;
// when a call that you sent out is rejected
- (void) onCallReject:(CineCall *)call;
// generic error catcher
- (void) handleError:(NSDictionary *)error;
[cinePeerClient startMediaStream];
NSString *roomName = @"example";
[cinePeerClient joinRoom:roomName];
You'll need to set the secretKey on the config to identify.
[config setSecretKey:CINE_IO_SECRET_KEY];
NSString *identityName = @"UNIQUE-IDENTITY";
CineIdentity *identity = [config generateIdentity:identityName];
[self.cinePeerClient identify:identity];
NSString *identityName = @"UNIQUE-IDENTITY-TO-CALL";
[self.cinePeerClient call:identity];
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request