Events
Creating and managing events with the ContactsManager SDK
Events
The ContactsManager SDK provides comprehensive event management features to enhance your app with social events and activities. Events can be used for scheduling meetups, announcing product launches, organizing team activities, or any other social interactions within your app. This guide explains how to implement these features using the SDK.
Event Flexibility
The event system in ContactsManager is designed to be highly flexible, allowing you to model various types of social interactions beyond traditional calendar events. Using the eventType
field (a free-form string) and the metadata
field (a customizable JSON object), you can implement a wide range of social features:
Use Cases for Events
- Calendar Events: Traditional meetups, appointments, or gatherings with time and location
- Social Posts: Status updates, photos, or announcements similar to Instagram or Facebook posts
- Activity Feed Items: Transactions or actions like those in Venmo (“Alex paid Bob $20”)
- Product Launches: Announcements of new features or products
- Milestones: Achievements or important dates for users
- Content Recommendations: Suggested articles, videos, or other content
- Group Activities: Team events, group challenges, or collaborative projects
Customizing Events with Metadata
The metadata
field accepts any JSON data, making it extremely versatile:
By creatively using these fields, you can build rich social features that perfectly match your app’s requirements without being limited to a rigid event structure.
Creating an Event
Creating events allows users to share activities and gatherings with their network. Events contain essential information like title, location, time, and visibility settings that determine who can see them.
The CreateEventRequest
model includes these key properties:
eventType
: A categorical identifier for the event (e.g., meeting, social, post, transaction)title
: The main title of the eventdescription
: Detailed information about the eventlocation
: Where the event will take placestartTime
andendTime
: When the event begins and endsmetadata
: Additional custom data as key-value pairsisPublic
: Determines whether the event is visible to all users or only specific contacts
Example: Creating a Social Post Event
Example: Creating a Transaction Activity
Retrieving Event Details
Once an event is created, users can view its details. This is useful for displaying event information on dedicated event pages or when users receive event invitations.
The retrieved SocialEvent
object contains all the event properties including the creator’s information and event visibility settings, allowing you to build rich event detail interfaces.
Updating an Event
Event details may need to be modified after creation. Changes to time, location, or other details can be easily updated using the update method.
The UpdateEventRequest
model is similar to the creation model, but all fields are optional. Only the properties you want to change need to be included, and existing properties will remain unchanged if not specified.
Example: Updating a Social Post Event
Deleting an Event
When events are cancelled or no longer needed, they can be removed from the system, which prevents them from appearing in feeds and search results.
Deleting an event is a permanent operation, so consider implementing confirmation flows in your app UI to prevent accidental deletions.
Event Feeds
The SDK provides different feed types to display events from users. These feeds are essential for creating engaging social experiences within your app.
Following Feed
The Following Feed shows events from users the user follows, creating a personalized stream of relevant activities. This helps users stay informed about what people in their network are doing.
”For You” Feed
The “For You” feed includes all public events in the user’s network, not limited to people they follow. This broader feed helps users discover new connections and activities they might be interested in.
Upcoming Events
The Upcoming Events feed shows events scheduled in the future, helping users plan ahead and manage their calendar. This is particularly useful for displaying “events near you” or “happening soon” sections.
User Events
This feed shows events created by a specific user, which is useful for profile pages or when browsing a particular user’s activities.
All feed methods support pagination through the skip
and limit
parameters, allowing you to implement infinite scrolling or load-more functionality.
Filtering Events by Type
When building specialized feeds, you may want to filter events by type. This can be done by processing the events returned by the feed methods:
Building an Event Interface
Here’s an example of building an event detail view with SwiftUI, demonstrating how to create a polished and functional event interface:
This example shows a complete event detail view with dynamic content based on event type. You can adapt this interface to match your app’s design and requirements.
This example demonstrates how to:
- Load and display event details
- Handle loading states and errors
- Format date and time information
- Create an intuitive layout with proper visual hierarchy
- Implement action buttons for user interaction
- Dynamically display different UI based on event type and metadata
Best Practices for Events
- Validation: Implement client-side validation for event data to ensure all required fields are filled correctly before submission
- Timezone Handling: Be explicit about timezones when displaying event times to avoid confusion for users in different locations
- Cancellation Flow: Implement a proper flow for cancelling or rescheduling events, including notifications to affected users
- Event Reminders: Provide options for users to set reminders for events, improving user engagement and attendance
- Calendar Integration: Make it easy for users to add events to their device calendars with a simple tap
- Pagination: Implement proper pagination for event lists to maintain performance with large datasets
- Event Types: Create a consistent taxonomy of event types across your app for better filtering and display
- Metadata Structure: Document your metadata structure for different event types to ensure consistency
Troubleshooting
Common Issues
-
Date Formatting Issues
- Ensure proper date formatting across different locales by testing on various device settings
- Be explicit about timezones when working with event dates, especially for events with global attendance
-
Event Visibility
- Check the
isPublic
flag when creating events to ensure proper visibility settings - Ensure proper permissions are set for viewing private events, especially in multi-user contexts
- Check the
-
Loading Performance
- Use pagination to improve performance when loading large event lists
- Implement caching for frequently accessed events to reduce network requests
- Consider prefetching upcoming events data to improve perceived performance