The Gruveo SDK for iOS and a sample project.
To add the Gruveo SDK for iOS to your app, you will need CocoaPods, which is a dependency manager for Objective-C. You can install CocoaPods with the following command:
$ gem install cocoapods
To integrate the Gruveo SDK into your Xcode project using CocoaPods, add the GruveoSDK
pod to your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'TargetName' do
pod 'GruveoSDK'
end
Then, run the following command:
$ pod install
NSCameraUsageDescription
and NSMicrophoneUsageDescription
to your application's Info.plistGruveoSDK
to the AppDelegate
and your ViewController
class:
@import GruveoSDK;
[GruveoCallManager setClientId:@"demo”]
GruveoCallManager
in the viewDidLoad
function:
[GruveoCallManager setDelegate:self]
[GruveoCallManager callCode:@"hello" videoCall:YES onViewController:self callCreationCompletion:^(CallInitError creationError) {
if (creationError != CallInitErrorNone) {
// Show error here
}
}];
Implement the delegate function for token signing. Warning: The sample implementation below uses a signing endpoint provided by Gruveo and will only work for the demo
client ID:
- (void)requestToSignApiAuthToken:(NSString *)token {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api-demo.gruveo.com/signer"]];
[request setHTTPMethod:@"POST"];
[request setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[token dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:nil delegateQueue:nil];
[[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if ([data isKindOfClass:[NSData class]]) {
NSString *signedToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[GruveoCallManager authorize:signedToken];
} else {
[GruveoCallManager authorize:nil];
}
}] resume];
}
- (void)callEstablished {}
- (void)callEnd:(GruveoCallEndReason)reason {}
- (void)recordingStateChanged {}