Docs

  • Channels Channels
  • Beams Beams
  • Developers
  • Support
  • Blog
  • Sign up
    • Search powered by Algolia
    • Sign in
    • Sign up
    • Channels
    • Getting started
      • SDK quick starts
        • JavaScript quick start
        • iOS quick start
        • Android quick start
        • Flutter quick start
        • React Native quick start
      • Use case quick starts
        • Javascript realtime chart
        • Javascript realtime user list
      • Debugging
    • Using channels
      • Client API overview
      • Connection
      • User authentication
      • Watchlist events
      • Functions
      • Authorized connections
      • Channels
      • Public channels
      • Private channels
      • Encrypted channels
      • Presence channels
      • Cache channels
      • Events
      • Global configuration
      • Websocket fallbacks
      • Device compatibility
    • Server api
      • Overview
      • HTTP API interaction
      • Webhooks
      • Authenticating users
      • Authorizing users
      • Sending events to authenticated users
      • Terminating user connections
      • Excluding event recipients
    • Channels libraries
      • API libraries
    • Pusher cli
      • Overview
      • Installation
      • Documentation
    • Miscellaneous
      • Clusters
      • Integrations
      • Resources
    • Library auth reference
      • Authentication and authorization signatures
      • HTTP API reference
      • Pusher Channels Protocol
      • Server library reference specification
      • Logging
    • Beams
    • Pusher lab

    Watchlist events

    ∞ What is a Watchlist?

    A Watchlist is a property associated with a user and provided during user authentication. A Watchlist is an array of user IDs which represent the circle of interest for the user (e.g., friends or followers). Users can be notified about the status (online/offline) of users they “watch”.

    ∞ Using Watchlist events

    In order to use Watchlist events, here are the prerequisites:

    1. Provide a Watchlist
    2. Enable Watchlist events
    3. Subscribe to Watchlist events

    ∞ Provide a Watchlist

    Providing a watchlist for a user is optional. However, in order to receive Watchlist events, you need to provide the Watchlist during User Authentication.

    ∞ Enable Watchlist events

    For Watchlist events to work, you must enable them for your application. To do that, go to the Channels dashboard, navigate to your app and App Settings, and turn on the Watchlist events toggle.

    ∞ Subscribe to Watchlist events

    The client-side can subscribe to Watchlist events by using Client SDKs. The client-side needs to call pusher.signin() to start the user authentication process. Then, you can use pusher.user.watchlist.bind() to bind to Watchlist events. Example:

    pusher.signin();

    const watchlistEventHandler = (event) => {
    // event.user_ids
    // event.name
    };
    pusher.user.watchlist.bind('online', watchlistEventHandler);
    pusher.user.watchlist.bind('offline', watchlistEventHandler);

    ∞ Watchlist Online Status

    The Online Status feature notifies a user about the status of the users in their watchlist. It indicates whether a user ID is online or offline for each user ID in the watchlist.

    Once the user is authenticated, they will receive events indicating the current online status of peers in their watchlist. The user will continue to receive events for any further changes to the online status of users in the watchlist.

    Receiving notifications about who in your circle is online or offline is useful in many scenarios.

    Events associated with Online Status for Watchlists are:

    • online
    • offline

    A user is considered online if that user is authenticated on at least one connection. A user can be authenticated on many connections and is still considered online. If a user is not authenticated on any connections, the user is considered offline.

    Here’s a sequence diagram to showcase how the Watchlist Online Status works.

    Watchlist Online - Status Sequence Diagram

    Contents

    • What is a Watchlist?
    • Using Watchlist events
    • Provide a Watchlist
    • Enable Watchlist events
    • Subscribe to Watchlist events
    • Watchlist Online Status

    Spotted something that isn’t quite right? Create an issue on GitHub.

    Copyright © 2023 Pusher Ltd. All rights reserved.

    • Support,
    • Status
    • Follow Pusher on Twitter Twitter
    • Subscribe to Pusher’s channel on YouTube
    • Follow Pusher on LinkedIn
    • Follow Pusher on Github GitHub
    • Follow Pusher on Twitch Twitch
    • Follow Pusher on Discord Discord