Agora RTC Objective-C API Reference Refactor

Instance Methods
AgoraRtmPresence Class Reference

Inherits <NSObject>.

## Instance Methods
(void) | - whoNow:channelType:options:completion:
(void) | - getOnlineUsers:channelType:options:completion:
(void) | - whereNow:completion:
(void) | - getUserChannels:completion:
(void) | - setState:channelType:items:completion:
(void) | - removeState:channelType:keys:completion:
(void) | - getState:channelType:userId:completion:

## Detailed Description

The IRtmPresence class.

This class provides the rtm presence methods that can be invoked by your app.

## Method Documentation

## ◆ NS_UNAVAILABLE

- (instancetype _Nullable) NS_UNAVAILABLE |  |  |

## ◆ whoNow:channelType:options:completion:

- (void) whoNow: |  | (NSString *_Nonnull) | channelName
channelType: |  | (AgoraRtmChannelType) | channelType
options: |  | (AgoraRtmPresenceOptions *_Nullable) | options
completion: |  | (AgoraRtmWhoNowBlock _Nullable) | completionBlock

To query who joined this channel

Parameters

  channelName | The name of the channel.
  channelType | The type of the channel.
  options | The query option.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ getOnlineUsers:channelType:options:completion:

- (void) getOnlineUsers: |  | (NSString *_Nonnull) | channelName
channelType: |  | (AgoraRtmChannelType) | channelType
options: |  | (AgoraRtmGetOnlineUsersOptions *_Nullable) | options
completion: |  | (AgoraRtmGetOnlineUsersBlock _Nullable) | completionBlock

To query who joined this channel

Parameters

  channelName | The name of the channel.
  channelType | The type of the channel.
  options | The query option.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ whereNow:completion:

- (void) whereNow: |  | (NSString *_Nonnull) | userId
completion: |  | (AgoraRtmWhereNowBlock _Nullable) | completionBlock

To query which channels the user joined

Parameters

  userId | The id of the user.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ getUserChannels:completion:

- (void) getUserChannels: |  | (NSString *_Nonnull) | userId
completion: |  | (AgoraRtmGetUserChannelsBlock _Nullable) | completionBlock

To query which channels the user joined

Parameters

  userId | The id of the user.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ setState:channelType:items:completion:

- (void) setState: |  | (NSString *_Nonnull) | channelName
channelType: |  | (AgoraRtmChannelType) | channelType
items: |  | (NSDictionary< NSString *, NSString * > *_Nonnull) | items
completion: |  | (AgoraRtmOperationBlock _Nullable) | completionBlock

Set user state

Parameters

  channelName | The name of the channel.
  channelType | The type of the channel.
  items | The states item of user.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ removeState:channelType:keys:completion:

- (void) removeState: |  | (NSString *_Nonnull) | channelName
channelType: |  | (AgoraRtmChannelType) | channelType
keys: |  | (NSArray< NSString * > *_Nonnull) | keys
completion: |  | (AgoraRtmOperationBlock _Nullable) | completionBlock

Delete user state

Parameters

  channelName | The name of the channel.
  channelType | The type of the channel.
  keys | The keys of state item.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.

## ◆ getState:channelType:userId:completion:

- (void) getState: |  | (NSString *_Nonnull) | channelName
channelType: |  | (AgoraRtmChannelType) | channelType
userId: |  | (NSString *_Nonnull) | userId
completion: |  | (AgoraRtmPresenceGetStateBlock _Nullable) | completionBlock

Get user state

Parameters

  channelName | The name of the channel.
  channelType | The type of the channel.
  userId | The id of the user.
  completionBlock | The operation result will be notified by completionBlock, if operation success，will given a not nil response and nil errorInfo，if operation failed，will given a nil response and not nil errorInfo.