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 theeventType
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
Themetadata
field accepts any JSON data, making it extremely versatile:
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.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.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.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.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.Upcoming Events
The Upcoming Events feed shows events scheduled in the future, helping users plan ahead.User Events
This feed shows events created by a specific user, which is useful for profile pages.skip
and limit
parameters, allowing you to implement infinite scrolling or load-more functionality.
Filtering Events by Type
The API provides server-side filtering by event type, which is more efficient than client-side filtering. Use theeventType
parameter in feed requests to get only the events you need:
Available Event Types
The API supports filtering by these common event types:"social_post"
- Social media style posts with images, text, hashtags"transaction"
- Payment or financial transactions"meeting"
- Calendar events and appointments"activity"
- General activities and milestones"announcement"
- Product launches and announcements"recommendation"
- Content or product recommendations
Performance Benefits
Server-side filtering provides several advantages over client-side filtering:- Reduced bandwidth: Only relevant events are transferred
- Better performance: No need to fetch and filter large datasets
- Consistent pagination: Skip/limit work correctly with filtered results
- Database optimization: Indexes can be used for efficient filtering
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.
EventDetailView.swift
- 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