// Add a reaction to an activity
let reaction = try await feed.addReaction(
activityId: "activity_123",
request: .init(
custom: ["emoji": "❤️"],
type: "like"
)
)
// Remove a reaction
_ = try await feed.removeReaction(activityId: "activity_123", type: "like")
Activity Feeds V3 is in closed alpha — do not use it in production (just yet).
Reactions
Overview
You can react to both activities and comments. It’s possible to configure any reaction types that best fit your app.
const addResponse = await client.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
});
console.log(addResponse.reaction);
const deleteResponse = await client.deleteActivityReaction({
activity_id: "activity_123",
type: "like",
});
console.log(deleteResponse.reaction);
const addResponse = await client.feeds.addReaction({
activity_id: "activity_123",
type: "like",
custom: {
emoji: "❤️",
},
user_id: "reacting_user_id",
});
console.log(addResponse.reaction);
const deleteResponse = await client.feeds.deleteActivityReaction({
activity_id: "activity_123",
type: "like",
user_id: "reacting_user_id",
});
console.log(deleteResponse.reaction);
By default creating a reaction doesn’t create an activity.
When you read a feed the reactions are included. Here’s an example:
let feedData = try await feed.getOrCreate()
// Last 15 reactions on the first activity
print(feed.state.activities[0].latestReactions)
// Count of reactions by type
print(feed.state.activities[0].reactionGroups)
const feed = client.feed("user", "sara");
await feed.getOrCreate();
console.log(feed.state.getLatestValue().activities?.[0].own_reactions);
console.log(feed.state.getLatestValue().activities?.[0].latest_reactions);
console.log(feed.state.getLatestValue().activities?.[0].reaction_groups);
const feed = client.feeds.feed("user", "sara");
const response = await feed.getOrCreate({ user_id: "sara" });
console.log(response.activities[0].own_reactions);
console.log(response.activities[0].latest_reactions);
console.log(response.activities[0].reaction_groups);
On this page: