Proje: OkulUp · Hub: OkulUp — Architecture
Real-Time Infrastructure
WebSocket: Laravel Echo + Pusher
Kütüphaneler: laravel-echo ^2.3.0, pusher-js ^8.4.0
Config: EXPO_PUBLIC_REVERB_KEY, EXPO_PUBLIC_REVERB_HOST, EXPO_PUBLIC_REVERB_PORT env var’larından okunuyor
Lifecycle
useWebSocket() hook’u root layout’ta (AppContent) çalışıyor:
- Token + user varsa
initEcho(token)ile bağlanır - User kanalına subscribe:
subscribeToUserNotifications(user.id, callback) - Notification gelince
notificationSlice.incrementByType(payload.type)çağrılır - App background’a geçince disconnect, foreground’a gelince reconnect
Kanallar
subscribeToConversation(conversationId, callbacks) // chat mesajları
subscribeToUserNotifications(userId, callback) // genel bildirimlerPayload tipleri: NewMessagePayload, MessageReadPayload, TypingPayload, NewNotificationPayload
Push Notifications: Expo Notifications
Kütüphane: expo-notifications ~0.32.16
Flow
- Login başarılı →
setupPushNotifications()çağrılır - Push token alınır + backend’e register edilir
- Logout →
unregisterToken(token)→ backend’den kaldırılır (logout’u bloklamamak için try/catch)
Handler
setupNotificationHandlers() — root layout useEffect’inde mount’ta çağrılır:
- Notification’a tıklanınca
resolveNotificationRoute(payload)ile ilgili sayfaya navigate eder setNotificationSoundPref()vesetNotificationVibrationPref()user preference’a göre ayarlanıyor
NotificationBanner
Uygulama açıkken gelen push’lar için custom in-app banner (NotificationBanner component)
Root layout’ta render edilmiş, notificationBannerEmitter event emitter ile tetikleniyor
Badge Counting
notificationSlice’ta tutuluyor: unreadTotal, unreadConversations, unreadAnnouncements
Hem TabBar hem AppHeader bu değerleri okuyor
Related
- state-management — notificationSlice
- navigation-architecture — deep link routing