@@ -8,6 +8,7 @@ KNotify is a Kotlin library for sending native notifications across different op
8
8
- Simple, unified API for sending notifications
9
9
- Customizable notification title, message, and application icon
10
10
- Automatic selection of the appropriate notifier based on the operating system
11
+ - Application name customization for better identification
11
12
12
13
## Installation
13
14
@@ -33,14 +34,15 @@ Here's a simple example of how to use KNotify:
33
34
import com.kdroid.knotify.NotifierFactory
34
35
35
36
fun main () {
36
- val notifier = NotifierFactory .getNotifier()
37
-
37
+ val appName = " MyApp"
38
+ val notifier = NotifierFactory .getNotifier(appName)
39
+
38
40
val title = " Hello from KNotify"
39
41
val message = " This is a test notification"
40
42
val appIcon = " /path/to/your/app/icon.png"
41
-
43
+
42
44
val success = notifier.notify(title, message, appIcon)
43
-
45
+
44
46
if (success) {
45
47
println (" Notification sent successfully" )
46
48
} else {
@@ -55,34 +57,38 @@ fun main() {
55
57
56
58
``` kotlin
57
59
interface Notifier {
58
- fun notify (title : String , message : String , appIcon : String ): Boolean
60
+ fun notify (title : String , message : String , appIcon : String? ): Boolean
59
61
}
60
62
```
61
63
62
64
- ` title ` : The title of the notification
63
65
- ` message ` : The message content of the notification
64
- - ` appIcon ` : The path to the application icon to display with the notification (Note: not supported on macOS )
66
+ - ` appIcon ` : The path to the application icon to display with the notification (can be null )
65
67
- Returns: ` true ` if the notification was successfully sent, ` false ` otherwise
66
68
67
69
### NotifierFactory
68
70
69
71
``` kotlin
70
72
object NotifierFactory {
71
- fun getNotifier (): Notifier
73
+ fun getNotifier (appName : String ): Notifier
72
74
}
73
75
```
74
76
75
- - ` getNotifier() ` : Returns a platform-specific implementation of the ` Notifier ` interface based on the current operating system
77
+ - ` appName ` : The name of the application sending the notification
78
+ - Returns: A platform-specific implementation of the ` Notifier ` interface based on the current operating system
76
79
77
80
## Platform Support
78
81
79
82
- Linux: Uses ` LinuxNotifier `
80
83
- Windows: Uses ` WindowsNotifier `
81
84
- macOS: Uses ` MacNotifier `
82
85
83
- ## Note
86
+ Each platform-specific notifier is initialized with the provided ` appName ` .
87
+
88
+ ## Notes
84
89
85
- The ` appIcon ` parameter is not yet supported on macOS.
90
+ - The ` appIcon ` parameter is optional (can be null) and is not yet supported on macOS.
91
+ - An ` UnsupportedOperationException ` is thrown if the current operating system is not supported.
86
92
87
93
## Contributing
88
94
0 commit comments