Use case: Create a reaction to an annotation
Before you start
Before you create a reaction to an annotation, ensure you have completed the following prerequisites:
- Verify Permissions: Confirm that you have the necessary rights to add reactions to annotations. This typically requires being a member of the project with appropriate permissions.
- Existing Annotation: You must have an existing annotation to which you want to add the reaction. Make sure you have its unique identifier.
- Understand Available Reactions: Familiarize yourself with the types of reactions supported by the system. Common reactions include:
- 👍 (Thumbs up / Like)
- 👎 (Thumbs down / Dislike)
- ❤️ (Heart)
- 😄 (Laugh)
- 😮 (Surprised)
- 🎯 (Bullseye)
- ✅ (Checkmark)
- Consider Reaction Context: Understand the purpose and implications of reactions in your team's workflow. Reactions provide quick feedback without cluttering the discussion thread.
- Set Up SDK Environment: Ensure your Unity environment is properly configured with the Collaboration SDK to interact with the annotation system.
How do I...?
Add a standard reaction to an annotation
To add a predefined reaction to an existing annotation:
- Obtain the Project Identifier: Ensure you have the correct project identifier (GUID) for the project.
- Identify the Annotation: Determine which annotation should receive the reaction.
- Choose the Reaction Type: Select one of the standard reaction types supported by the system.
- Create the Reaction: Use the SDK to add the reaction to the annotation.
- Handle UI Updates: Update your user interface to reflect the newly added reaction, typically by incrementing a counter and highlighting that the current user has reacted.
- Validate Support: Ensure the system supports the specific emoji before attempting to use it.
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.CreateAnnotationReactionAsync(
projectId: projectId,
annotationId: annotationId,
code: code,
cancellationToken: cancellationToken);
If a user has already reacted to an Annotation with the given emoji, then this operation does nothing.
Handle reaction creation errors and duplicates
To manage potential errors or duplicate reactions:
- Implement Error Handling: Add robust error handling for the reaction creation process.
- Check for Duplicates: Handle cases where a user might try to add the same reaction multiple times.
For more information on working with reactions, see the documentation on deleting reactions.