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
- Add
NSCameraUsageDescription
andNSMicrophoneUsageDescription
to your application's Info.plist - Set “Enable Bitcode” to NO in Target -> Build Settings -> Enable Bitcode
- Check the "Audio, AirPlay, and Picture in Picture" checkbox under Capabilities -> Background Modes
- Import
GruveoSDK
to theAppDelegate
and yourViewController
class:
@import GruveoSDK;
- Register your сlient ID after application startup:
[GruveoCallManager setClientId:@"demo”]
- Set delegate for
GruveoCallManager
in theviewDidLoad
function:
[GruveoCallManager setDelegate:self]
- Implement creation of the Gruveo call screen:
[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];
}
- Implement the other useful delegate functions:
- (void)callEstablished {}
- (void)callEnd:(GruveoCallEndReason)reason {}
- (void)recordingStateChanged {}
- Build and run your application.