Subscribe to social platform events including communities, posts, comments, and user activities
Social real-time events enable live updates for social features through topic subscriptions. A topic is a distinct path constructed for each model you wish to subscribe to, with helper methods provided for each model type.
To subscribe to updates from a community or its content, users must have ‘Member’ status. Leaving a community automatically stops event delivery.
// Subscribe to post eventslet eventTopic1 = AmityPostTopic(post: post, andEvent: .post)subscriptionManager.subscribeTopic(eventTopic1) { success, error in // Handle Result}// Subscribe to comment eventslet eventTopic2 = AmityPostTopic(post: post, andEvent: .comments)subscriptionManager.subscribeTopic(eventTopic2) { success, error in // Handle Result}
// Subscribe to user eventslet eventTopic1 = AmityUserTopic(user: user, andEvent: .user)subscriptionManager.subscribeTopic(eventTopic1) { success, error in // Handle the result}
// Subscribe to story eventslet eventTopic1 = AmityStoryTopic(story: story, andEvent: .story)subscriptionManager.subscribeTopic(eventTopic1) { success, error in // Handle the result}