Suggestions

close search

StringeeClient

@interface StringeeClient : NSObject

Represents a Stringee client, manages the client's connection. This class provides methods to connect to/disconnect from Stringee server, receives the connection's events, the incoming call event.

userId

It's the unique identification of the client on Stringee system.

@property (strong, nonatomic, readonly) NSString *userId;
hasConnected

Whether the client connects to Stringee server:
- hasConnected = YES, connected.
- hasConnected = No, not connected.

@property (assign, nonatomic, readonly) BOOL hasConnected;
connectionDelegate

A delegate to monitor the connection's events. For more information, see StringeeConnectionDelegate

@property (weak, nonatomic) id connectionDelegate;
incomingCallDelegate

A delegate to monitor when having an incoming call. For more information, see StringeeIncomingDelegate

@property (weak, nonatomic) id incomingCallDelegate;
- initWithConnectionDelegate:

Creates a new StringeClient instance and registers a connectionDelegate object.

- (instancetype)initWithConnectionDelegate:(id)delegate;
- connectWithAccessToken:

Connects to Stringee server with an access token.

From SDK 2.2.0: while the client is connected, calling this method with a new token for the same user (for example after requestAccessToken: is invoked shortly before the token expires) renews the token on the open connection without reconnecting. If the token has expired and the server has disconnected the client, call this method with a new token on the same StringeeClient instance to resume the session.

- (void)connectWithAccessToken:(NSString *)accessToken;
- updateToken:completionHandler:

Renews the access token on the open connection without reconnecting. Call it after tokenWillExpire:exp:expireInSeconds: is invoked on the current connection, with a new token for the same user. On success, the client keeps the new token and also uses it for automatic reconnects. Available from SDK 2.2.0:
- token: The new access token.
completionHandler returns the result of the renewal:
- status = YES, code = 0: The token is renewed.
- status = NO, code > 0: Error returned by the server, for example code = 6 (token expired), code = 10 (invalid signature), code = 17 (token for another user or project). Other server codes are reported as authentication errors.
- status = NO, code = -1: The client is not connected to Stringee Server.
- status = NO, code = -2: The token is empty.
- status = NO, code = -4: The server did not respond within 10 seconds.
- status = NO, code = -5: The server has not requested renewal on this connection: tokenWillExpire:exp:expireInSeconds: has not been invoked, or the server does not support token expiration.

- (void)updateToken:(NSString *)token completionHandler:(void(^)(BOOL status, int code, NSString *message))completionHandler;
- sendCustomMessage:toUserId:completionHandler:

Send a custom message to a user:
- message: Message to send.
- userId: User id to send a custom message to.
- status = YES, code = 0, message = "Success"
- status = NO, code = -1, message = "The client is not connected to Stringee Server."
- status = NO, code = -2, message = "toUserId is invalid."
- status = NO, code = -3, message = "Message can not be nil."

- (void)sendCustomMessage:(NSDictionary *)message toUserId:(NSString *)userId completionHandler:(void(^)(BOOL status, int code, NSString *message))completionHandler;
- registerPushForDeviceToken:isProduction:isVoip:completionHandler:

Register device token to receive push notification. When you have an incoming call, you receive a notification from Stringee server:
- deviceToken: the token received from Apple's server when you register push notification to Apple.
- isProduction = YES : For production environment, isProduction = NO: For development environment.
- isVoip = YES: To receive voip push notification, isVoip = NO: To receive remote push notification.
completionHandler returns the result of the registration:
- status = YES, code = 0, message = "Register successfully." or message = "Register successfully. This device token is already registered.".
- status = NO, code = 1, message = "Register failed. The Bundle Identifier has not been configured.".
- status = NO, code = -1, message = "Register failed. The client is not connected to Stringee Server".
- status = NO, code = -2, message = "Register failed. Data is empty.".
- status = NO, code = -3, message = "Register failed. Generic error.".

- (void)registerPushForDeviceToken:(NSString *)deviceToken isProduction:(BOOL)isProduction isVoip:(BOOL)isVoip completionHandler:(void(^)(BOOL status, int code, NSString * message))completionHandler;
- unregisterPushForDeviceToken:completionHandler:

Remove your device token from Stringee server. Your device will not receive push notification when you have an incoming call:
deviceToken: The device token which registered.
completionHandler: Returns the result of unregistering:
- status = YES, code = 0, message = "Unregister successfully." or message = "Unregister successfully. This device token is not on the system.".
- status = NO, code = 1, message = "Unregister failed. The Bundle Identifier has not been configured.".
- status = NO, code = -1, message = "Unregister failed. The client is not connected to Stringee Server".
- status = NO, code = -2, message = "Unregister failed. Generic error".

- (void)unregisterPushForDeviceToken:(NSString *)deviceToken completionHandler:(completion)completionHandler;
- disconnect:

Disconnects from Stringee server.

- (void)disconnect;