-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customize notifications. Kotlin DSL syle, and Notification Image supp…
…ort (#95) * Adding Dsl style builder to Notifier notify method * Notification Image support for android * Android Notification Image using File path * Ios notification image support
- Loading branch information
1 parent
9d2f50a
commit 763a3f9
Showing
11 changed files
with
319 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/NotificationImage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.mmk.kmpnotifier.notification | ||
|
||
public sealed class NotificationImage { | ||
/** | ||
* Url of image. Make sure you gave internet permission | ||
*/ | ||
public data class Url(val url: String) : NotificationImage() | ||
|
||
/** | ||
* File path. Make sure app can read this file | ||
*/ | ||
public data class File(val path: String) : NotificationImage() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
kmpnotifier/src/commonMain/kotlin/com/mmk/kmpnotifier/notification/NotifierBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.mmk.kmpnotifier.notification | ||
|
||
import kotlin.random.Random | ||
|
||
public class NotifierBuilder { | ||
|
||
public var id: Int = Random.nextInt(0, Int.MAX_VALUE) | ||
public var title: String = "" | ||
public var body: String = "" | ||
|
||
public var payloadData: Map<String, String> = emptyMap() | ||
|
||
public var image: NotificationImage? = null | ||
|
||
public fun payload(block: MutableMap<String, String>.() -> Unit) { | ||
payloadData = mutableMapOf<String, String>().apply(block) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.