Use case: Delete a reaction from an annotation
Before you start
Before you delete a reaction from an annotation, ensure you have completed the following prerequisites:
- Verify Permissions: Confirm that you have the necessary rights to remove reactions from annotations. Typically, you can only remove reactions that you yourself have added, unless you have administrative permissions.
- Identify the Specific Reaction: Determine the exact reaction you want to remove. You'll need both the annotation identifier and the specific reaction type to target the correct reaction.
- Understand Reaction Deletion Implications: Be aware that removing a reaction will immediately update the reaction count visible to all users. In collaborative environments, this may affect the perceived sentiment toward the annotation.
- Check Reaction Ownership: Verify that the reaction you're trying to delete was added by the current user (or that you have administrative permissions to remove others' reactions).
- Set Up SDK Environment: Ensure your Unity environment is properly configured with the Collaboration SDK to interact with the annotation system.
How do I...?
Remove a user's own reaction from an annotation
To remove a reaction that the current user has previously added:
- Obtain the Project Identifier: Ensure you have the correct project identifier (GUID) for the project.
- Identify the Annotation and Reaction: Determine which annotation and specific reaction type to remove.
- Delete the Reaction: Use the SDK to remove the specified reaction.
- Update UI Display: Update your user interface to reflect the removed reaction, typically by decrementing the reaction counter and removing the highlight indicating the user had reacted.
Example:
var projectId = new ProjectId("example-project-id");
var annotationId = new AnnotationId("example-annotation-id");
var code = "thumbs_up"; // Reaction code for 👍
var cancellationToken = new CancellationTokenSource().Token;
await annotationManagement.DeleteAnnotationReactionAsync(
projectId: projectId,
annotationId: annotationId,
code: code,
cancellationToken: cancellationToken);
A user can only remove a reaction they’ve previously added. If a user tries to remove a Reaction when there is none, an error will be returned.
For more information on working with reactions, see the documentation on creating reactions.