# Presence (/en/realtime-media/rtm/build/manage-presence-and-metadata/presence/ios)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

In Signaling solutions, it is often important to know a user's current online status. For example, in instant messaging, chat applications, and online collaboration tools, users need to see the availability of their contacts. This information is typically displayed as a status message or icon next to a user's name. Presence features in Signaling SDK enable you to monitor join, leave, and status change notifications for users in a channel. Using Presence, you can:

    * Get a list of users currently in a channel and their temporary status data.
    * Get a list of channels a specified user has joined or is subscribed to.
    * Get, set, or remove user statuses.
    * Receive real-time event notifications when users join or leave specified channels.
    * Receive user status change event notifications in real time.

    ## Understand the tech [#understand-the-tech-2]

    Presence provides real-time information about the availability, and the current status of users, for effective communication and collaboration. It enables you to retrieve a list of users in a channel, or to query the list of channels for a specific user. The following figure illustrates how you integrate presence features into your app.

    **Presence workflow**

    ![Presence workflow](https://assets-docs.agora.io/images/signaling/presence-workflow.svg)

    ## Prerequisites [#prerequisites-2]

    Ensure that you have integrated the Signaling SDK in your project, and implemented the framework functionality from the [SDK quickstart](../../quickstart) page.

    <CalloutContainer type="info">
      <CalloutDescription>
        Presence features require Signaling SDK version 2.2.0 or later.
      </CalloutDescription>
    </CalloutContainer>

    ## Implement presence features [#implement-presence-features-2]

    Using presence, you can implement the following features:

    ### Get channel users [#get-channel-users-2]

    To obtain a list of online users in a channel, call `getOnlineUsers`. Depending on your parameter settings, this method returns a list of online user IDs in a channel and their temporary status data, or just the number of online users in the channel. You do not need to join a channel to call this method. This method is applicable to both message channels and stream channels. Use the `channelType` parameter to specify the channel type.

    <CalloutContainer type="info">
      <CalloutDescription>
        After obtaining the initial online users list, update it in real time through `didReceivePresenceEvent` event notifications.
      </CalloutDescription>
    </CalloutContainer>

    Refer to the following sample code to query the list of online users in a channel and their current status:

    <Tabs defaultValue="swift" groupId="language">
      <TabsList>
        <TabsTrigger value="swift">
          Swift
        </TabsTrigger>

        <TabsTrigger value="objc">
          Objective-C
        </TabsTrigger>
      </TabsList>

      <TabsContent value="swift">
        ```swift
        let presenceOptions = AgoraRtmPresenceOptions()
        presenceOptions.includeState = true
        presenceOptions.includeUserId = true

        // Retrieve the user state of the current channel
        rtm.getPresence()?.getOnlineUsers(channelName: "your_channel", channelType: .message, options: presenceOptions) { response, errorInfo in
            if errorInfo == nil {
                print("getOnlineUsers success!!")
                let userCount = response?.totalOccupancy ?? 0
                let userStates = response?.userStateList ?? []

                // You can process userCount and userStates here
            } else {
                print("getOnlineUsers failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```
      </TabsContent>

      <TabsContent value="objc">
        ```objc
        AgoraRmPresenceOptions* presence_opt = [[AgoraRtmPresenceOptions alloc] init];
        presence_opt.includeState = true;
        presence_opt.includeUserId = true;
        [[rtm getPresence] getOnlineUsers:@"your_channel" channelType:AgoraRtmChannelTypeMessage options:presence_opt completion:^(AgoraRtmgetOnlineUsersResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"getOnlineUsers success!!");
                int user_count = response.totalOccupancy;
                NSArray<AgoraRtmUserState *> * user_states = response.userStateList;
            } else {
                NSLog(@"getOnlineUsers failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```

        The `getOnlineUsers` method retrieves one page of data at a time. Each page contains up to 100 online users. If the channel has more than 100 users, the `response.nextPage` field contains a bookmark for the next page. After each query, check `response.nextPage` to determine if there is more data. To retrieve the next page, set the `page` field in `AgoraRtmPresenceOptions` to the value of `response.nextPage`. Repeat this process until `response.nextPage` is empty.
      </TabsContent>
    </Tabs>

    <CodeBlockTabs defaultValue="Swift">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Swift">
          Swift
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Objective-C">
          Objective-C
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Swift">
        ```swift
        let presenceOptions = AgoraRtmPresenceOptions()
        presenceOptions.includeState = true
        presenceOptions.includeUserId = true
        presenceOptions.page = "your_Next_Page_Bookmark"

        // Retrieve the user state of the current channel
        rtm.getPresence()?.getOnlineUsers("your_channel", channelType: .message, options: presenceOptions) { response, errorInfo in
            if errorInfo == nil {
                print("getOnlineUsers success!!")

                let userCount = response?.totalOccupancy ?? 0
                let nextPage = response?.nextPage ?? ""
                let userStates = response?.userStateList ?? []

                // You can process userCount, nextPage, and userStates here
            } else {
                print("getOnlineUsers failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Objective-C">
        ```objc
        AgoraRtmPresenceOptions* presence_opt = [[AgoraRtmPresence alloc] init];
        presence_opt.includeState = true;
        presence_opt.includeUserId = true;
        presence_opt.page = @"your_Next_Page_Bookmark";

        [[rtm getPresence] getOnlineUsers:@"your_channel" channelType:AgoraRtmChannelTypeMessage options:presence_opt completion:^(AgoraRtmgetOnlineUsersResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"getOnlineUsers success!!");
                int user_count = response.totalOccupancy;
                NSString* next_page = response.nextPage;
                NSArray<AgoraRtmUserState *> * user_states = response.userStateList;
            } else {
                NSLog(@"getOnlineUsers failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    When there is a large number of users in a channel, you may only care about the total number of online users, and not their identities or temporary status. To get the total channel occupancy, set `includeState` and `includeUserId` in `AgoraRtmPresenceOptions` to `false`.

    <CodeBlockTabs defaultValue="Swift">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Swift">
          Swift
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Objective-C">
          Objective-C
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Swift">
        ```swift
        let presenceOptions = AgoraRtmPresenceOptions()
        presenceOptions.includeState = false
        presenceOptions.includeUserId = false

        // Retrieve the user state of the current channel
        rtm.getPresence()?.getOnlineUsers(channelName: "your_channel", channelType: .message, options: presenceOptions) { response, errorInfo in
            if errorInfo == nil {
                print("getOnlineUsers success!!")

                let userCount = response?.totalOccupancy ?? 0
            } else {
                print("getOnlineUsers failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Objective-C">
        ```objc
        AgoraRtmPresenceOptions* presence_opt = [[AgoraRtmPresence alloc] init];
        presence_opt.includeState = false;
        presence_opt.includeUserId = false;

        [[rtm getPresence] getOnlineUsers:@"your_channel" channelType:AgoraRtmChannelTypeMessage options:presence_opt completion:^(AgoraRtmgetOnlineUsersResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"getOnlineUsers success!!");
                int user_count = response.totalOccupancy;
            } else {
                NSLog(@"getOnlineUsers failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    In this case, only the `totalOccupancy` property in the result is valid while all other fields are empty.

    <CalloutContainer type="info">
      <CalloutDescription>
        You cannot set `includeState` to `true` and `includeUserId` to `false` at the same time. To get the temporary status of users, you must also retrieve their user IDs.
      </CalloutDescription>
    </CalloutContainer>

    ### Get user channels [#get-user-channels-2]

    The `getUserChannels` method enables you to query which channels a user is currently in. This includes the message channels a user has subscribed to and the stream channels they have joined. This method is particularly useful for tracking user paths. Refer to the following sample code:

    <CodeBlockTabs defaultValue="Swift">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Swift">
          Swift
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Objective-C">
          Objective-C
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Swift">
        ```swift
        rtm.getPresence()?.getUserChannels("userId") { response, errorInfo in
            if errorInfo == nil {
                print("getUserChannels success!!")

                let channelCount = response?.totalChannel ?? 0
                let channels = response?.channels ?? []

            } else {
                print("getUserChannels failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Objective-C">
        ```objc
        [[rtm getPresence] getUserChannels:@"userId" completion:^(AgoraRtmGetUserChannelsResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"getUserChannels success!!");
                int channel_count = response.totalChannel;
                NSArray<AgoraRtmChannelInfo *> * channels = response.channels;
            } else {
                NSLog(@"getUserChannels failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    The `getUserChannels` method returns complete query results about the channels and their types that the queried user is in, without pagination.

    ## User status management [#user-status-management-2]

    Signaling enables you to set and delete user status messages for the local user in each channel. The SDK notifies other online users in the channel of these changes through event notifications. This feature is useful in use-cases where user status sharing is required, such as real-time synchronization of the user's microphone status, mood, personal signature, score, and message input status.

    Signaling does not permanently save the status data. When a user unsubscribes from a channel, times out, or exits a channel, the data is deleted. To save user data permanently, refer to [Store user metadata](storage/store-user-metadata).

    When a user's temporary status changes, Signaling triggers the remote state changed event notification in real-time. Users who enable presence in `features` when subscribing to a channel, receive the event notification.

    ### Set status [#set-status-2]

    Using presence, you can set the temporary user status for the local user. When you set the status before subscribing to or joining a channel, the data is cached on the client and does not take effect immediately. The status is updated and corresponding event notifications are triggered when you subscribe to or join a channel. The `setState` method applies to both message and stream channels; use the `channelType` parameter to specify the channel type.

    <CodeBlockTabs defaultValue="Swift">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Swift">
          Swift
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Objective-C">
          Objective-C
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Swift">
        ```swift
        let states: [String: String] = ["key1": "value1", "key2": "value2"]

        rtm.getPresence()?.setState(channelName: "your_channel", channelType: .message, items: states) { response, errorInfo in
            if errorInfo == nil {
                print("setState success!!")
            } else {
                print("setState failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Objective-C">
        ```objc
        NSDictionary *states = @{@"key1": @"value1", @"key2": @"value2"};

        [[rtm getPresence] setState:@"your_channel" channelType:AgoraRtmChannelTypeMessage items:states completion:^(AgoraRtmCommonResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"setState success!!");
            } else {
                NSLog(@"setState failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    When using `setState` to set temporary user status, if the specified key already exists, its value is overwritten by the new value. If the specified key does not exist, a new key-value pair is added.

    ### Get status [#get-status-2]

    To obtain the temporary user status set by a user in a specified channel, use the `getState` method:

    <Tabs defaultValue="swift" groupId="language">
      <TabsList>
        <TabsTrigger value="swift">
          Swift
        </TabsTrigger>

        <TabsTrigger value="objc">
          Objective-C
        </TabsTrigger>
      </TabsList>

      <TabsContent value="swift">
        ```swift
        rtm.getPresence()?.getState(channelName: "Chat_room", channelType: .message, userId: "userid") { response, errorInfo in
            if errorInfo == nil {
                print("getState success!!")

                if let state = response?.state {
                    // process state
                }
            } else {
                print("getState failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```

        If the queried user is not present in the specified channel, a `presenceUserNotExist` error message is returned by the SDK.
      </TabsContent>

      <TabsContent value="objc">
        ```objc
        [[rtm getPresence] getState:@"Chat_room" channelType:AgoraRtmChannelTypeMessage userId:@"userid" completion:^(AgoraRtmPresenceGetStateResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"getState success!!");
                AgoraRtmUserState* state = response.state;
            } else {
                NSLog(@"getState failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```

        Use the `getState` method to obtain the temporary status of other online users in the channel. If the queried user is not present in the specified channel, a `AgoraRtmErrorPresenceUserNotExist` error message is returned by the SDK.
      </TabsContent>
    </Tabs>

    ### Delete status [#delete-status-2]

    Each user can set up to 32 key-value pairs in a channel. To remove items that are no longer needed, call `removeState` with a list of keys. The `removeState` method only deletes temporary user status data for the local user.

    <Tabs defaultValue="swift" groupId="language">
      <TabsList>
        <TabsTrigger value="swift">
          Swift
        </TabsTrigger>

        <TabsTrigger value="objc">
          Objective-C
        </TabsTrigger>
      </TabsList>

      <TabsContent value="swift">
        ```swift
        let keys: [String] = ["key1", "key2"]

        rtm.getPresence()?.removeState("your_channel", channelType: .message, keys: keys) { response, errorInfo in
            if errorInfo == nil {
                print("removeState success!!")
            } else {
                print("removeState failed, errorCode \\(errorInfo!.errorCode), reason \\(errorInfo!.reason)")
            }
        }
        ```

        Both the `setState` and `removeState` methods trigger `remoteStateChanged` event notifications. Users who join the channel with presence enabled in `features` receive event notifications containing full data of the user's temporary status.
      </TabsContent>

      <TabsContent value="objc">
        ```objc
        NSArray<NSString*>* keys = @[@"key1", @"key2"];
        [[rtm getPresence] removeState:@"your_channel" channelType:AgoraRtmChannelTypeMessage keys:keys completion:^(AgoraRtmCommonResponse * _Nullable response, AgoraRtmErrorInfo * _Nullable errorInfo) {
            if (errorInfo == nil) {
                NSLog(@"removeState success!!");
            } else {
                NSLog(@"removeState failed, errorCode %d, reason %@", errorInfo.errorCode, errorInfo.reason);
            }
        }];
        ```

        Both the `setState` and `removeState` methods trigger `AgoraRtmPresenceEventTypeRemoteStateChanged` event notifications. Users who subscribe to the channel with presence enabled in `features` receive event notifications containing full data of the user's temporary status.
      </TabsContent>
    </Tabs>

    ## Receive presence event notifications [#receive-presence-event-notifications-2]

    A presence event notification returns the [AgoraRtmPresenceEvent](/en/api-reference/api-ref/signaling#configpresenceeventpropsag_platform) data structure, which includes the [AgoraRtmPresenceEventType](/en/api-reference/api-ref/signaling#enumvpresencetypepropsag_platform) parameter.

    To receive presence event notifications, implement an event listener. See [event listeners](/en/api-reference/api-ref/signaling#event-listeners) for details. In addition, include presence in the `features` parameter when subscribing to or joining a channel.

    ### Event notification modes [#event-notification-modes-2]

    The presence event notification mode determines how subscribed users receive event notifications. There are two notification modes:

    * `Announce`: Real-time notification mode
    * `Interval`: Scheduled notification mode

    Set the **Max number of instant event** value in Agora Console to specify the condition for switching between the two modes. The scheduled notification mode helps prevent event noise that results from a large number of online users in the channel. See [Presence configuration](../../manage-agora-account#presence-configuration) for details.

    #### Real-time notification mode [#real-time-notification-mode-2]

    If the number of instant notifications in the channel is less than the **Max number of instant event** value, presence event notifications operate in real-time notification mode. In this mode, the following notifications are sent to the client in real-time:

    **Swift**

    * `remoteJoinChannel`
    * `remoteLeaveChannel`
    * `remoteConnectionTimeout`
    * `remoteStateChanged`

    <CodeBlockTabs defaultValue="Join">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Join">
          Join
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Leave">
          Leave
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Timeout">
          Timeout
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Snapshot">
          Snapshot
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="State change">
          State change
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Join">
        ```js
        {
            type: .remoteJoinChannel;
            channelType: .message;
            channelName: "test_channel";
            publisher: "publisher_name";
            states: [];
            interval: [];
            snapshot: [];
            timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Leave">
        ```js
        {
            eventType: .remoteLeaveChannel;
            channelType: .message;
            channelName: "test_channel";
            publisher: "publisher_name";
            stateChanged: [];
            interval: [];
            snapshot: [];
            timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Timeout">
        ```js
        {
            eventType: .remoteConnectionTimeout;
            channelType: .message;
            channelName: "test_channel";
            publisher: "publisher_name";
            stateChanged: [];
            interval: [];
            snapshot: [];
            timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Snapshot">
        ```js
        {
            eventType: .snapshot;
            channelType: .message;
            channelName: "test_channel";
            publisher: "";
            stateChanged: [];
            interval: [];
            snapshot: [
                { userId: "user_a", states: {}},
                { userId: "user_b", states: { key_1: "value_1" }},
                { userId: "yourSelf", states: {}},
            ];
            timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="State change">
        ```js
        {
            eventType: .remoteStateChanged;
            channelType: .message;
            channelName: "test_channel";
            publisher: "publisher_name";
            states: {
                "key_1": "value_1",
            };
            interval: [];
            snapshot: [];
            timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    **Objective-C**

    * `AgoraRtmPresenceEventTypeRemoteJoinChannel`
    * `AgoraRtmPresenceEventTypeRemoteLeaveChannel`
    * `AgoraRtmPresenceEventTypeRemoteConnectionTimeout`
    * `AgoraRtmPresenceEventTypeRemoteStateChanged`

    <CodeBlockTabs defaultValue="Join">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Join">
          Join
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Leave">
          Leave
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Timeout">
          Timeout
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Snapshot">
          Snapshot
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="State change">
          State change
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Join">
        ```js
        {
              type: AgoraRtmPresenceEventTypeRemoteJoinChannel;
              channelType: AgoraRtmChannelTypeMessage;
              channelName: "test_channel";
              publisher: "publisher_name";
              states: [];
              interval: [];
              snapshot: [];
              timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Leave">
        ```js
        {
              eventType: AgoraRtmPresenceEventTypeRemoteLeaveChannel;
              channelType: AgoraRtmChannelTypeMessage;
              channelName: "test_channel";
              publisher: "publisher_name";
              stateChanged: [];
              interval: [];
              snapshot: [];
              timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Timeout">
        ```js
        {
              eventType: AgoraRtmPresenceEventTypeRemoteConnectionTimeout;
              channelType: AgoraRtmChannelTypeMessage;
              channelName: "test_channel";
              publisher: "publisher_name";
              stateChanged: [];
              interval: [];
              snapshot: [];
              timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Snapshot">
        ```js
        {
              eventType: AgoraRtmPresenceEventTypeSnapshot;
              channelType: AgoraRtmChannelTypeMessage;
              channelName: "test_channel";
              publisher: "";
              stateChanged: [];
              interval: [];
              snapshot: [
                  { userId: "user_a", states: {}},
                  { userId: "user_b", states: { key_1: "value_1" }},
                  { userId: "yourSelf", states: {}},
              ];
              timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>

      <CodeBlockTab value="State change">
        ```js
        {
              eventType: AgoraRtmPresenceEventTypeRemoteStateChanged;
              channelType: AgoraRtmChannelTypeMessage;
              channelName: "test_channel";
              publisher: "publisher_name";
              states: {
                  "key_1": "value_1",
              };
              interval: [];
              snapshot: [];
              timestamp: 1710487149497;
        }
        ```
      </CodeBlockTab>
    </CodeBlockTabs>

    #### Scheduled notification mode [#scheduled-notification-mode-2]

    <Tabs defaultValue="swift" groupId="language">
      <TabsList>
        <TabsTrigger value="swift">
          Swift
        </TabsTrigger>

        <TabsTrigger value="objc">
          Objective-C
        </TabsTrigger>
      </TabsList>

      <TabsContent value="swift">
        When the number of online users in a channel exceeds the **Max number of instant event** value, the channel switches to the scheduled notification mode. In this mode, `remoteJoinChannel`, `remoteLeaveChannel`, `remoteConnectionTimeout`, and `remoteStateChanged` events are replaced by `interval` events and sent to all users in the channel at specific time intervals. Users receive the following notification:

        ```js
        {
              "type": "AgoraRtmPresenceEventTypeInterval",
              "channelType": "AgoraRtmChannelTypeMessages",
              "channelName": "Chat_room",
              "publisher": "Tony",
              "interval": {
                  "remote_join": ["Tony", "Lily"],
                  "remote_leave": ["Jason"],
                  "remote_timeout": ["Wendy"],
                  "remote_state_change": [
                      {
                          "userId": "Harvard",
                          "states": [
                              { "Mic": "False" },
                              { "Position": "Washington" }
                          ]
                      },
                      {
                          "userId": "Harvard",
                          "states": [
                              { "Mic": "True" },
                              { "Position": "Washington" }
                          ]
                      }
                  ]
              }
        }
        ```
      </TabsContent>

      <TabsContent value="objc">
        When the number of online users in the channel exceeds the **Max number of instant event** value, the channel switches to the scheduled notification mode. In this mode, `AgoraRtmPresenceEventTypeRemoteJoinChannel`, `AgoraRtmPresenceEventTypeRemoteLeaveChannel`, `AgoraRtmPresenceEventTypeRemoteConnectionTimeout`, and `AgoraRtmPresenceEventTypeRemoteStateChanged` events are replaced by `AgoraRtmPresenceEventTypeInterval` events and sent to all users in the channel at specific time intervals. Users receive the following notification:

        ```js
        {
              "type": "AgoraRtmPresenceEventTypeInterval",
              "channelType": "AgoraRtmChannelTypeMessages",
              "channelName": "Chat_room",
              "publisher": "Tony",
              "interval": {
                  "remote_join": ["Tony", "Lily"],
                  "remote_leave": ["Jason"],
                  "remote_timeout": ["Wendy"],
                  "remote_state_change": [
                      {
                          "userId": "Harvard",
                          "states": [
                              { "Mic": "False" },
                              { "Position": "Washington" }
                          ]
                      },
                      {
                          "userId": "Harvard",
                          "states": [
                              { "Mic": "True" },
                              { "Position": "Washington" }
                          ]
                      }
                  ]
              }
        }
        ```
      </TabsContent>
    </Tabs>

    ## Reference [#reference-2]

    This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

    ### API reference [#api-reference-2]

    <Tabs defaultValue="swift" groupId="language">
      <TabsList>
        <TabsTrigger value="swift">
          Swift
        </TabsTrigger>

        <TabsTrigger value="objc">
          Objective-C
        </TabsTrigger>
      </TabsList>

      <TabsContent value="swift">
        * [`getOnlineUsers`](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#getonlineusers)
        * [`getUserChannels`](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#getuserchannels)
        * [`setState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#presencesetstatepropsag_platform)
        * [`getState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#presencegetstatepropsag_platform)
        * [`removeState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#presenceremovestatepropsag_platform)
        * [Event listeners](/en/api-reference/api-ref/signaling?platform=ios\&tab=swift#event-listeners)
      </TabsContent>

      <TabsContent value="objc">
        * [`getOnlineUsers`](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#getonlineusers)
        * [`getUserChannels`](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#getuserchannels)
        * [`setState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#presencesetstatepropsag_platform)
        * [`getState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#presencegetstatepropsag_platform)
        * [`removeState`](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#presenceremovestatepropsag_platform)
        * [Event listeners](/en/api-reference/api-ref/signaling?platform=ios\&tab=objc#event-listeners)
      </TabsContent>
    </Tabs>

    
  
      
  
      
  
      
  
      
  
      
  
