Protocols
The following protocols are available globally.
-
The SINAudioController provides methods for controlling audio related functionality, e.g. enabling the speaker, muting the microphone, and playing sound files.
Playing Sound Files
The audio controller provides a convenience method (startPlayingSoundFile:loop:) for playing sounds that are related to a call, such as ringtones and busy tones.
- Example:
id<SINAudioController> audio = [client audioController]; NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"ringtone" ofType:@"wav"]; [audio startPlayingSoundFile:soundPath loop:YES];
Applications that prefer to use their own code for playing sounds are free to do so, but they should follow a few guidelines related to audio session categories and audio session activation/deactivation (see Sinch SDK User Guide for details).
Sound File Format
The sound file must be a mono (1 channel), 16-bit, uncompressed (PCM) .wav file with a sample rate of 8kHz, 16kHz, or 32kHz.
See moreDeclaration
Objective-C
@protocol SINAudioController <NSObject>
Swift
protocol SINAudioController : NSObjectProtocol
-
The delegate of a SINAudioController object must adopt the SINAudioControllerDelegate protocol. The methods handle audio related state changes.
See moreDeclaration
Objective-C
@protocol SINAudioControllerDelegate <NSObject>
Swift
protocol SINAudioControllerDelegate : NSObjectProtocol
-
The SINCall represents a call.
See moreDeclaration
Objective-C
@protocol SINCall <NSObject>
Swift
protocol SINCall : NSObjectProtocol
-
The delegate of a SINCall object must adopt the SINCallDelegate protocol. The required methods handle call state changes.
Call State Progression
For a complete outgoing call, the delegate methods will be called in the following order:
callDidProgress:
callDidEstablish:
callDidEnd:
For a complete incoming call, the delegate methods will be called in the following order, after the client delegate method
[SINClientDelegate client:didReceiveIncomingCall:]
has been called:callDidEstablish:
callDidEnd:
Declaration
Objective-C
@protocol SINCallDelegate <NSObject>
Swift
protocol SINCallDelegate : NSObjectProtocol
-
SINCallClient provides the entry point to the calling functionality of the Sinch SDK. A SINCallClient can be acquired via SINClient.
Exmaple:
id<SINClient> sinchClient; [sinchClient start]; ... // Place outgoing call. id<SINCallClient> callClient = [sinchClient callClient]; id<SINCall> call = [callClient callUserWithId:@"<REMOTE USERID>"]; // Set the call delegate that handles all the call state changes call.delegate= ... ; // ... // Hang up the call [call hangup];
Declaration
Objective-C
@protocol SINCallClient <NSObject>
Swift
protocol SINCallClient : NSObjectProtocol
-
The delegate of a SINCallClient object must adopt the SINCallClientDelegate protocol.
See moreDeclaration
Objective-C
@protocol SINCallClientDelegate <NSObject>
Swift
protocol SINCallClientDelegate : NSObjectProtocol
-
The SINCallDetails holds metadata about a call (SINCall).
See moreDeclaration
Objective-C
@protocol SINCallDetails <NSObject>
Swift
protocol SINCallDetails : NSObjectProtocol
-
SINCallNotificationResult is used to indicate the result of
-[SINClient relayRemotePushNotificationPayload:]
when the Sinch-specific payload in the notification represents an incoming call.One example of a scenario where SINCallNotificationResult is when a user have been attempted to be reached, but not acted on the notification directly. In that case, the notification result object can indicate that the notification is too old (
See moreisTimedOut
), and also contains theremoteUserId
which can be used for display purposes.Declaration
Objective-C
@protocol SINCallNotificationResult <NSObject>
Swift
protocol SINCallNotificationResult : NSObjectProtocol
-
The SINClient is the Sinch SDK entry point.
It provides access to the feature classes in the Sinch SDK: SINCallClient and SINAudioController. It is also used to configure the user’s and device’s capabilities.
User Identification
The user IDs that are used to identify users application specific.
Important
user IDs are restricted to the character set “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghjiklmnopqrstuvwxyz0123456789-_=”, and must be no longer than 255 bytes.
Example:
// Instantiate a client object using the client factory. id<SINClient> client = [Sinch clientWithApplicationKey:@"<APPLICATION KEY>" environmentHost:@"ocra.api.sinch.com" userId:@"<USERID>"]; // Enable push notifications [client enableManagedPushNotifications]; // Assign delegate. It is required to implement // -[SINClientDelegate client:requiresRegistrationCredentials:] // and provide a authorization token (JWT) to allow the User to register // and the client to successfully start. client.delegate = ... ; // Start the client [client start]; // Use SINCallClient to place and receive calls [client.callClient callUserWithId:...]
Declaration
Objective-C
@protocol SINClient <NSObject>
Swift
protocol SINClient : NSObjectProtocol
-
The delegate of a SINClient object must adopt the SINClientDelegate protocol. The required methods allows responding to client state changes (start and stop), and providing user registration credentials (JWT).
See moreDeclaration
Objective-C
@protocol SINClientDelegate <NSObject>
Swift
protocol SINClientDelegate : NSObjectProtocol
-
Callback object to be used to proceed in user registration process when registration credentials for the user in question have been obtained.
See moreDeclaration
Objective-C
@protocol SINClientRegistration <NSObject>
Swift
protocol SINClientRegistration : NSObjectProtocol
-
SINManagedPushDelegate
See moreDeclaration
Objective-C
@protocol SINManagedPushDelegate <NSObject>
Swift
protocol SINManagedPushDelegate : NSObjectProtocol
-
SINNotificationResult is used to indicate the result of
-[SINClient relayPushNotification:]
and+[SINManagedPush queryPushNotificationPayload:]
.- Example:
id<SINNotificationResult> result = [self.client relayPushNotification:payload]; if ([result isCall] && [result callResult].isTimedOut) { NSString* remoteUserId = [result callResult].remoteUserId; // Present UI indicating user missed the call. }
It can be especially useful for scenarios which will not result in the SINClientDelegate receiving any callback for an incoming call as a result of calling the methods mentioned above. One such scenario is when a user have been attempted to be reached, but not acted on the notification directly. In that case, the notification result object can indicate that the notification is too old (
See moreisTimedOut
), and also contains theremoteUserId
which can be used for display purposes.Declaration
Objective-C
@protocol SINNotificationResult <NSObject>
Swift
protocol SINNotificationResult : NSObjectProtocol
-
The SINVideoController provides methods for controlling video related functionality.
See moreDeclaration
Objective-C
@protocol SINVideoController <NSObject>
Swift
protocol SINVideoController : NSObjectProtocol
-
Video frame handler must adopt SINVideoFrameCallback protocol
See moreDeclaration
Objective-C
@protocol SINVideoFrameCallback <NSObject>
Swift
protocol SINVideoFrameCallback : NSObjectProtocol