AgoraChatSDK 1.3.1
|
#import <AgoraChatClient.h>
Class Methods | |
(instancetype _Nonnull) | + sharedClient |
Protected Attributes | |
AgoraChatPushOptions * | _pushOptions |
Properties | |
NSString *_Nonnull | version |
NSString *_Nullable | currentUsername |
AgoraChatOptions *_Nonnull | options |
id< IAgoraChatManager > _Nullable | chatManager |
id< IAgoraChatContactManager > _Nullable | contactManager |
id< IAgoraChatGroupManager > _Nullable | groupManager |
id< IAgoraChatThreadManager > _Nullable | threadManager |
id< IAgoraChatroomManager > _Nullable | roomManager |
id< IAgoraChatPushManager > _Nullable | pushManager |
BOOL | isAutoLogin |
BOOL | isLoggedIn |
BOOL | isConnected |
NSString *_Nullable | accessUserToken |
id< IAgoraChatUserInfoManager > _Nullable | userInfoManager |
id< IAgoraChatPresenceManager > _Nullable | presenceManager |
id< IAgoraChatStatisticsManager > _Nullable | statisticsManager |
This class is the entry of the Chat SDK, which is responsible for management of modules like login, logout, and connection.
With this class, you can access other modules such as group [AgoraChatClient sharedClient].groupManager.
- (void) addDelegate: | (id< AgoraChatClientDelegate >_Nonnull) | aDelegate | |
delegateQueue: | (dispatch_queue_t _Nullable) | aQueue | |
Adds a delegate.
aDelegate | The delegate that you want to add. |
aQueue | (optional) The queue of calling delegate methods. If you want to run the app on the main thread, set this parameter as nil . |
- (void) addLogDelegate: | (id< AgoraChatLogDelegate >_Nonnull) | aDelegate | |
delegateQueue: | (addLog(delegate:queue:)) | NS_SWIFT_NAME | |
Adds the log callback delegate.
aDelegate | The delegate that you want to add. |
aQueue | The queue of calling delegate methods. |
- (void) addMultiDevicesDelegate: | (id< AgoraChatMultiDevicesDelegate >_Nonnull) | aDelegate | |
delegateQueue: | (addMultiDevices(delegate:queue:)) | NS_SWIFT_NAME | |
Adds the multi-device delegate.
aDelegate | The delegate that you want to add. |
aQueue | The queue of calling delegate methods. |
- (void) application: | (id _Nonnull) | application | |
didReceiveRemoteNotification: | (NSDictionary *_Nullable) | userInfo | |
Occurs when the device receives an APNs notification when your app is running in the foreground.
This event is specific to the iOS platform.
application | The current application instance. |
userInfo | The push content. |
- (void) applicationDidEnterBackground: | (id _Nonnull) | aApplication |
Disconnects from the chat server when the app is switched to the background.
This method is specific to the iOS platform.
aApplication | The current application instance. |
- (void) applicationWillEnterForeground: | (id _Nonnull) | aApplication |
Reconnects to the server when your app returns to the foreground.
This method is specific to the iOS platform.
aApplication | The current application instance. |
- (AgoraChatError *_Nullable) bindDeviceToken: | (NSData *_Nonnull) | aDeviceToken |
Binds the device token.
Device token binding is required to enable Apple Push Notification Service.
This is a synchronous method and blocks the current thread.
aDeviceToken | The device token to bind. |
@Result If the binding succeeds, the SDK returns nil
; otherwise, the SDK returns the description of the issue that causes the call to fail.
- (void) bindFCMToken: | (NSString *_Nonnull) | aFCMToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Binds the FCM token, call this API when integrated FCM Notification
This is an asynchronous method.
aFCMToken | The device token generated by FCM SDK. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
@Result If the binding succeeds, the SDK returns nil
; otherwise, the SDK returns the description of the issue that causes the call to fail.
- (AgoraChatError *_Nullable) bindPushKitToken: | (NSData *_Nullable) | aPushToken |
Uses the PushKit token to bind the user and the device, which is required to enable Apple PushKit Service.
The Apple PushKit service is used to implement VoIP push notifications.
This is a synchronous method and blocks the current thread.
aPushToken | The PushKit token to bind. |
- (AgoraChatError *_Nullable) changeAppkey: | (NSString *_Nonnull) | aAppkey |
Updates the the App Key, the unique identifier used to access the chat server.
You can only update the App Key when you are logged out.
aAppkey | The new App Key. |
@Result A description of the issue that caused this call to fail.
- (void) fetchTokenWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | (void(^)(NSString *_Nullable aToken, AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Fetches the token from the server.
This is an asynchronous method.
aUsername | The user ID. |
aPassword | The password. |
aCompletionBlock | The completion block, which contains the token and the error message if the method fails. |
- (AgoraChatDeviceConfig *) getDeviceConfig: | (AgoraChatError **) | pError |
Gets information of the current login device.
- (NSString *_Nullable) getLogFilesPath: | (AgoraChatError **_Nullable) | pError |
Compresses the debug logs into a gzip archive (.gz).
You are strongly advised to delete this debug archive once it is no longer used.
This is a synchronous method and blocks the current thread.
pError | A description of the issue that caused this call to fail. |
- (void) getLogFilesPathWithCompletion: | (void(^)(NSString *_Nullable aPath, AgoraChatError *_Nullable aError)) | aCompletionBlock |
Compresses the debug logs into a gzip archive (.gz).
You are strongly advised to delete this debug archive once it is no longer used.
This is an asynchronous method.
aCompletionBlock | The completion block, which contains the token and the error message if the method fails. |
- (void) getLoggedInDevicesFromServerWithUserId: | (NSString *_Nonnull) | aUserID | |
token: | (NSString *_Nonnull) | aToken | |
completion: | (void(^)(NSArray< AgoraChatDeviceConfig * > *_Nullable aList, AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Gets information of all login devices <AgoraChatDeviceConfig> from the server.
This is an asynchronous method.
aUserID | The user ID. |
aToken | The token. |
aCompletionBlock | The completion block, which contains the list and the error message if the method fails. |
- (void) getLoggedInDevicesFromServerWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | (void(^)(NSArray< AgoraChatDeviceConfig * > *_Nullable aList, AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Gets information of all login devices from the server.
This is an asynchronous method.
aUsername | The user ID. |
aPassword | The password. |
aCompletionBlock | The completion block, which contains the list and the error message if the method fails. |
- (NSArray< AgoraChatDeviceConfig * > *_Nullable) getLoggedInDevicesFromServerWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
error: | (AgoraChatError **_Nullable) | pError | |
Retrieves all devices a specified user is currently logged in to.
This is a synchronous method and blocks the current thread.
aUsername | The user ID used by the user to log in to the devices. |
aPassword | The password. |
pError | A description of the issue that caused this call to fail. |
- (AgoraChatError *_Nullable) initializeSDKWithOptions: | (AgoraChatOptions *_Nonnull) | aOptions |
Initializes the SDK.
aOptions | The SDK options. |
@Result A description of the issue that caused this call to fail.
- (void) kickAllDevicesWithUserId: | (NSString *_Nonnull) | aUserID | |
token: | (NSString *_Nonnull) | aToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Kicks a user out of the app on all devices.
This is an asynchronous method.
aUserID | The user ID. |
aToken | The token. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (AgoraChatError *_Nullable) kickAllDevicesWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
Kicks a user out of the app on all devices.
This is a synchronous method and blocks the current thread.
aUsername | The user ID of the user forced to log out of the app on all login devices. |
aPassword | The app login password of the user forced to log out of the app. |
- (void) kickAllDevicesWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Kicks a user out of the app on all devices.
This is an asynchronous method.
aUsername | The user ID of the user to be forced to log out of the app on all login devices. |
aPassword | The app login password of the user to be forced to log out of the app. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (void) kickDeviceWithUserId: | (NSString *_Nonnull) | aUserID | |
token: | (NSString *_Nonnull) | aToken | |
resource: | (NSString *_Nonnull) | aResource | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Kicks a user out of the app on a specific device.
You can call getLoggedInDevicesFromServerWithUserId
to retrieve the list of devices that a user is currently logged in to.
This is an asynchronous method.
aUserID | The user ID of the user to be kicked out of the app. |
aToken | The token. |
aResource | The device to log aUsername out from. Call getLoggedInDevicesFromServerWithUserId to retrieve the list of devices aUsername is currently logged into. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (AgoraChatError *_Nullable) kickDeviceWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
resource: | (NSString *_Nonnull) | aResource | |
Kicks a user out of the app on a specific device.
This is a synchronous method and blocks the current thread.
You can call getLoggedInDevicesFromServerWithUsername
to retrieve the list of devices that a user is currently logged in to.
aUsername | The user ID of the user to be kicked out of the app. |
aPassword | The password. |
aResource | The device to log the user out from. |
nil
; otherwise, the SDK returns the description of the issue that causes the call to fail. - (void) kickDeviceWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
resource: | (NSString *_Nonnull) | aResource | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Kicks a user out of the app on a specific device.
You can call getLoggedInDevicesFromServerWithUsername
to retrieve the list of devices that a user is currently logged in to.
This is an asynchronous method.
aUsername | The user ID of the user to be kicked out of the app. |
aPassword | The password. |
aResource | The device to log aUsername out from. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (void) log: | (NSString *_Nonnull) | aLog |
Outputs logs to a log file.
You can call this method after the SDK is initialized.
This is a synchronous method and blocks the current thread.
aLog | The log information to output. |
- (AgoraChatError *_Nullable) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
agoraToken: | (3_8_9) | ||
(4_2_0) | |||
("Use -AgoraChatClient loginWithUsername:token instead") | EM_DEPRECATED_IOS | ||
Logs in to the chat server with an Agora Chat user token.
This is a synchronous method and blocks the current thread. This method supports automatic login.
aUsername | The user ID. |
aAgoraToken | The Agora Chat user token. |
nil
; otherwise, the SDK returns the description of the issue that causes the call to fail. - (void) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
agoraToken: | (NSString *_Nonnull) | aAgoraToken | |
completion: | (3_8_9) | ||
(4_2_0) | |||
("Use -AgoraChatClient loginWithUsername:token:completion instead") | EM_DEPRECATED_IOS | ||
Logs in to the chat server with Agora Chat user token.
This is an asynchronous method. It supports automatic login.
aUsername | The user ID. |
aAgoraToken | The Agora Chat user token. |
aCompletionBlock | The callback of completion block, which contains the description of the cause to the issue if the method fails. |
- (AgoraChatError *_Nullable) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (3_0_0) | ||
(4_5_0) | |||
("Use -AgoraChatClient loginWithUsername:token:completion instead") | EM_DEPRECATED_IOS | ||
Logs in to the chat server with a password.
This is a synchronous method and blocks the current thread.
It is recommended that you log in to the chat service with a token.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aPassword | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
nil
; otherwise, the SDK returns the description of the issue that causes the call to fail. - (void) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | (3_0_0) | ||
(4_5_0) | |||
("Use -AgoraChatClient loginWithUsername:token:completion instead") | EM_DEPRECATED_IOS | ||
Logs in to the chat server with a password.
This is an asynchronous method.
It is recommended that you log in to the chat service with a token.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aPassword | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
aCompletionBlock | The completion block, which contains the username and the error message if the method fails. |
- (AgoraChatError *_Nullable) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
token: | (NSString *_Nonnull) | aToken | |
Logs in to the chat server with a token.
This method does not support automatic login.
This is a synchronous method and blocks the current thread.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aToken | The token for login to the chat server. |
nil
; otherwise, the SDK returns the description of the issue that causes the call to fail. - (void) loginWithUsername: | (NSString *_Nonnull) | aUsername | |
token: | (NSString *_Nonnull) | aToken | |
completion: | (void(^)(NSString *_Nonnull aUsername, AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Logs in to the chat server with a token.
This is an asynchronous method. This method supports automatic login.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aToken | The token for login to the chat server. |
aCompletionBlock | The completion block, which contains the user ID and the error message if the method fails. |
- (AgoraChatError *_Nullable) logout: | (BOOL) | aIsUnbindDeviceToken |
Logs out of the chat server.
This is a synchronous method and blocks the current thread.
aIsUnbindDeviceToken | Whether to unbind the user ID from the device.
|
- (void) logout: | (BOOL) | aIsUnbindDeviceToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Logs out of the chat server.
This is an asynchronous method.
aIsUnbindDeviceToken | Whether to unbind the user ID from the device.
|
aCompletionBlock | The completion block, which contains the token and the error message if the method fails. |
- (void) registerForRemoteNotificationsWithCertName: | (NSString *_Nonnull) | aCertName | |
deviceToken: | (NSData *_Nonnull) | aDeviceToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Registers the device token.
Device token binding is required to enable Apple push notification service.
This is an asynchronous method.
aCertName | The certification name to bind. |
aDeviceToken | The device token to bind. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (void) registerForRemoteNotificationsWithDeviceToken: | (NSData *_Nonnull) | aDeviceToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Registers the device token.
Device token binding is required to enable Apple push notification service.
This is an asynchronous method.
aDeviceToken | The device token to bind. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (void) registerPushKitToken: | (NSData *_Nullable) | aPushToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Registers a PushKit token.
The Apple PushKit service is used to implement VoIP push notifications.
This is an asynchronous method.
aPushToken | The PushKit token to register. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (AgoraChatError *_Nullable) registerWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
Registers a new user.
This method is not recommended and you are advised to call the RESTful API to register a new user.
After you call initializeSDKWithOptions
and register your app in the console, the app has access to all the features registered inside your chat network. You add and remove users inside your chat network; depending on how you implement your app, you control the people each user can see inside your network.
This is a synchronous method and blocks the current thread. To ensure the registration reliability, we recommend using the RESTful API to register new chat users.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aPassword | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
- (void) registerWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | (void(^)(NSString *_Nonnull aUsername, AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Registers a new user.
This is an asynchronous method. This method is not recommended and you are advised to call the RESTful API to register a user.
To ensure registration reliability, we recommend using the RESTful API to register new chat users.
aUsername | The user ID. The maximum length is 64 characters. Ensure that you set this parameter. Supported characters include the 26 English letters (a-z), the ten numbers (0-9), the underscore (_), the hyphen (-), and the English period (.). This parameter is case insensitive, and upper-case letters are automatically changed to low-case ones. If you want to set this parameter as a regular expression, set it as ^[a-zA-Z0-9_-]+$. |
aPassword | The password. The maximum length is 64 characters. Ensure that you set this parameter. |
aCompletionBlock | The completion block, which contains the username and the error message if the method fails. |
- (void) removeDelegate: | (id _Nonnull) | aDelegate |
Removes a delegate.
aDelegate | The delegate that you want to remove. |
- (void) removeLogDelegate: | (removeLog(delegate:)) | NS_SWIFT_NAME |
Removes the log callback delegate.
aDelegate | The log callback delegate that you want to delete. |
- (void) removeMultiDevicesDelegate: | (id< AgoraChatMultiDevicesDelegate >_Nonnull) | aDelegate |
Removes the multi-device delegate.
aDelegate | The multi-device delegate that you want to delete. |
- (AgoraChatError *_Nullable) renewToken: | (NSString *_Nonnull) | newToken |
Renews the user token when the current token expires.
If you are logged in with an Chat user token and you are notified via the ClientDelegate callback that the token is about to expire, you can call this method to renew the token to prevent unknown issues caused by an invalid token.
This is a synchronous method and blocks the current thread.
newToken | The new Chat token。 |
- (void) renewToken: | (NSString *_Nonnull) | newToken | |
completion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock | |
Renews the user token when the current token expires.
If you are logged in with an Chat user token and you are notified via the ClientDelegate callback that the token is about to expire, you can call this method to renew the token to prevent unknown issues caused by an invalid token.
This is an asynchronous method.
newToken | The new Chat token。 |
- (void) serviceCheckWithUsername: | (NSString *_Nonnull) | aUsername | |
password: | (NSString *_Nonnull) | aPassword | |
completion: | ("This method is deprecated") | __deprecated_msg | |
Runs the server diagnostic test for a specific user.
These tests are run in the order defined by AgoraChatServerCheckType.
If the user is logged in, the login account is used by default.
This is an asynchronous method.
aUsername | The user ID. |
aPassword | The password. |
aCompletionBlock | The completion block, which contains the error message if the method fails. |
+ (instancetype _Nonnull) sharedClient |
Creates a Client instance. The Client class is the entry to the Chat SDK. You need to call this method to create a Client instance before calling any other methods.
- (AgoraChatError *_Nullable) unBindPushKitToken |
Unbinds the Apple PushKit token from the device.
This method plays the same role as the unRegisterPushKitTokenWithCompletion
method.
The Apple PushKit service is used to implement VoIP push notifications.
This is a synchronous method and blocks the current thread.
- (void) unRegisterPushKitTokenWithCompletion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock |
Unregisters the Apple PushKit token.
This method plays the same role as the unBindPushKitToken
method.
This is an asynchronous method.
The Apple PushKit service is used to implement VoIP push notifications.
aCompletionBlock | The completion block, which contains the error message if the method fails. |
- (void) uploadDebugLogToServerWithCompletion: | (void(^)(AgoraChatError *_Nullable aError)) | aCompletionBlock |
Uploads the debug log to the chat server.
aCompletionBlock | The completion block, which contains the token and the error message if the method fails. |
- (AgoraChatError *_Nullable) uploadLogToServer |
Uploads the log to the chat server.
The information in the debug log is used by our engineers to fix errors and improve system performance.
This is a synchronous method and blocks the current thread.
nil
; otherwise, the SDK returns the description of the issue that causes the call to fail. - (NSString *) version |
The SDK version number.
|
readnonatomicassign |
The token used by the current user to access the chat server.
The user needs to use the user ID and password for the first login. If the login succeeds, a token is returned and the user can use it for subsequent logins.
|
readnonatomicstrong |
The chat manager module.
|
readnonatomicstrong |
The contact manager module.
|
readnonatomicstrong |
The ID of the user currently logged in to your chat app.
|
readnonatomicstrong |
The group manager module.
|
readnonatomicassign |
Whether to allow a user to automatically log in to the chat server with the user ID used last time.
YES
:Yes.NO
:No.
If the login fails, for example, because of an incorrect password or a deactivated user account, this parameter will be reset to NO
. In this case, you need to set it back to YES
to allow automatic login.
|
readnonatomicassign |
Whether the SDK is connected to the chat server.
YES
:Yes.NO
:No.
|
readnonatomicassign |
Whether the current user is already logged in to the chat server.
YES
:The current user is already logged in.NO
:The current user is not logged in.
|
readnonatomicstrong |
The SDK setting options. For example, whether to use HTTPs by default.
|
readnonatomicstrong |
The presence manager module.
|
readnonatomicstrong |
The push manager module.
|
readnonatomicstrong |
The chat room manager module.
|
readnonatomicstrong |
The message statistics manager module.
|
readnonatomicstrong |
The thread manager module.
|
readnonatomicstrong |
The user attribute manager module.
|
readnonatomicstrong |
The SDK version number.