ergvein
ergvein copied to clipboard
Notifications for android
Provide reflex API to create system notification about event.
newtype ChannelId = ChannelId { unChannelId :: Int }
data NotificationPriority = PriorityMin | PriorityLow | PriorityDefault | PriorityHigh
data NotificationCategory = CategoryAlarm | CategoryCall | CategoryEmail | CategoryError | CategoryEvent | CategoryMessage | CategoryNavigation | CategoryProgress | CategoryPromo | CategoryRecommendation | CategoryReminder | CategoryService | CategorySocial | CategoryStatus | CategorySystem | CategoryTransport
data NotificationVisibility = VisibilitySecret | VisibilityDefault | VisibilityPublic
-- Follows Android API where priority and importance are different types
data ChannelImportance = ImportanceMin | ImportanceLow | ImportanceDefault | ImportanceHigh
data NotificationChannel = {
notchanTitle :: !Text
, notchanDescr :: !Text
, notchanImportance :: !ChannelImportance
}
-- Reference to the pictures in our bundle
type ResourceName = Text
data Notification m = Notification {
notificationTitle :: !Text
, notificationText :: !Text
, notificationChannel :: !ChannelId
, notificationIcon :: !ResourceName
, notificationPriority :: !NotificationPriority
, notificationCategory :: !(Maybe NotificationCategory)
, notificationVisibility :: !NotificationVisibility
, notificationAction :: !(m ()) -- ^ Widget to switch to on tap on the notification
}
registerChannel :: Event t NotificationChannel -> m (Event t ChannelId)
postNotification :: Event t (Notification m) -> m (Event t ())
Reference https://developer.android.com/training/notify-user/build-notification
Additional task:
- Make it as separate library