Skip to main content
Logo
Explore APIsContact Us
  • Home
  1. Resources
  2. Virtual Stadium
  3. Notifications

Notifications

Receive and manage Central Hub notifications.


#Notification Types

The CentralHubNotificationsProvider manages three types of notifications:

Bet Share Notifications

Alerts when users you follow share new bets. Includes bet details and user information.

Comment Notifications

Notifies when someone comments on your shared bets. Tracks unread comment counts.

Social Notifications

Updates about new followers, reactions to your bets, and other social interactions.

#Managing Notifications

Mark individual notifications as read by ID or mark all notifications read at once.

The state includes separate unread counts for each notification type, enabling targeted UI updates.


#Usage

kotlin
class NotificationsViewModel : ViewModel(), KoinComponent {
    
    private val notificationsProvider: 
        CentralHubNotificationsProvider = get()
    
    val notificationsState = notificationsProvider.state
    
    init {
        notificationsProvider.loadData()
    }
    
    fun markAsRead(notificationIds: List<String>) {
        notificationsProvider.readNotifications(notificationIds)
    }
    
    fun markAllRead() {
        notificationsProvider.readAllNotifications()
    }
    
    override fun onCleared() {
        super.onCleared()
        notificationsProvider.destroy()
    }
}

Compose UI:

kotlin
@Composable
fun NotificationsScreen(
    viewModel: NotificationsViewModel = viewModel()
) {
    val state by viewModel.notificationsState
        .collectAsStateWithLifecycle()
    
    Column {
        // Unread counts
        Text("Unread Bets: ${state.numOfUnreadBetSlips}")
        Text("Unread Comments: ${state.numOfUnreadComments}")
        Text("Unread Social: ${state.numOfUnreadSocial}")
        
        // Notifications list
        LazyColumn {
            items(state.betslipNotifications) { notification ->
                BetNotificationCard(notification) {
                    viewModel.markAsRead(listOf(notification.id))
                }
            }
            
            items(state.commentNotifications) { notification ->
                CommentNotificationCard(notification)
            }
            
            items(state.socialNotifications) { notification ->
                SocialNotificationCard(notification)
            }
        }
    }
}

#Data Models

#CentralHubNotificationsState

State for notifications:

kotlin
data class CentralHubNotificationsState(
    val numOfNewNotifications: Int,
    val numOfUnreadBetSlips: Int,
    val numOfUnreadSocial: Int,
    val numOfUnreadComments: Int,
    val betslipNotifications: List<BetShareNotification>,
    val socialNotifications: List<SocialNotification>,
    val commentNotifications: List<CommentNotification>,
    val newFollowersData: NewFollowersData,
    val loadingState: LoadingStatus,
    // ... additional loading states
)

#Related Topics

  • Bet Sharing - Notifications for new bet shares
  • Comments & Reactions - Notifications for comments and reactions
  • Social Features - Notifications for new followers
Last updated about 2 months ago
Is this site helpful?
Virtual Stadium, Moderation, Engagement Tools, BET
Bet SharingComments & Reactions
On this page
  • Notification Types
  • Managing Notifications
  • Usage
  • Data Models
  • CentralHubNotificationsState
  • Related Topics