
Facilitates creation and management of customizable notifications with message, music, and progress styles. Allows setting click listeners and dismissing notifications individually or collectively.
commonMain.dependencies :
implementation("io.github.shadmanadman:knotif:0.68.0")
Note: In Android and iOS you need to set your app_icon and app_name inside AndroidManifest.xml and Info.plist respectively.
val messageData = KNotifMessageData(
id = "1",
title = "This is a test",
appName = "Knotif",
message = "This is a test message",
poster = imageResource(Res.drawable.default_poster),
appIcon = imageResource(Res.drawable.default_app_icon),
)
// Show the notification
Knotif.show(messageData)
// Dismiss the notification
Knotif.dismiss(messageData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener to be called when a notification is clicked
Knotif.setOnBuildMessageKnotifListener {
println("notification clicked ${it}")
}
Note: This notification style for Android and iOS will be replaced with the new system music notification style in the future.
val musicData = KNotifMusicData(
id = "1",
title = "This is a test",
appName = "Knotif",
icons = MusicIcons(
poster = poster,
playIcon = playIcon,
pauseIcon = pauseIcon,
nextIcon = nextIcon,
previousIcon = previousIcon
),
artist = "Artist test",
isPlaying = true,
appIcon = appIcon,
)
// Show the notification
Knotif.show(musicData)
// Dismiss the notification
Knotif.dismiss(messageData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener
Knotif.setOnBuildMusicKnotifListener(
knotifClicked = {},
nextClicked = {},
previousClicked = {},
playPauseClicked = {})
val progressData = KNotifProgressData(
id = "1",
title = "This is a test",
description = "This is a test description",
appName = "Knotif",
progress = 50,
appIcon = appIcon
)
// Show the notification
Knotif.show(progressData)
// Dismiss the notification
Knotif.dismiss(progressData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener to be called when a notification is clicked
Knotif.setOnBuildProgressKnotifListener {
println("notification clicked ${it}")
}
commonMain.dependencies :
implementation("io.github.shadmanadman:knotif:0.68.0")
Note: In Android and iOS you need to set your app_icon and app_name inside AndroidManifest.xml and Info.plist respectively.
val messageData = KNotifMessageData(
id = "1",
title = "This is a test",
appName = "Knotif",
message = "This is a test message",
poster = imageResource(Res.drawable.default_poster),
appIcon = imageResource(Res.drawable.default_app_icon),
)
// Show the notification
Knotif.show(messageData)
// Dismiss the notification
Knotif.dismiss(messageData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener to be called when a notification is clicked
Knotif.setOnBuildMessageKnotifListener {
println("notification clicked ${it}")
}
Note: This notification style for Android and iOS will be replaced with the new system music notification style in the future.
val musicData = KNotifMusicData(
id = "1",
title = "This is a test",
appName = "Knotif",
icons = MusicIcons(
poster = poster,
playIcon = playIcon,
pauseIcon = pauseIcon,
nextIcon = nextIcon,
previousIcon = previousIcon
),
artist = "Artist test",
isPlaying = true,
appIcon = appIcon,
)
// Show the notification
Knotif.show(musicData)
// Dismiss the notification
Knotif.dismiss(messageData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener
Knotif.setOnBuildMusicKnotifListener(
knotifClicked = {},
nextClicked = {},
previousClicked = {},
playPauseClicked = {})
val progressData = KNotifProgressData(
id = "1",
title = "This is a test",
description = "This is a test description",
appName = "Knotif",
progress = 50,
appIcon = appIcon
)
// Show the notification
Knotif.show(progressData)
// Dismiss the notification
Knotif.dismiss(progressData.id)
// Dismiss all notifications
Knotif.dismissAll()
// Set a listener to be called when a notification is clicked
Knotif.setOnBuildProgressKnotifListener {
println("notification clicked ${it}")
}