mirzemehdi / KMPNotifier

Kotlin Multiplatform Push Notification Library targetting android, iOS, Desktop and Web (JS and Wasm)
http://mirzemehdi.com/KMPNotifier/
Apache License 2.0
340 stars 19 forks source link

Unable to send notifications with URI on Android devices #52

Closed HoucemK closed 3 months ago

HoucemK commented 4 months ago

Hi,

It's possible to find a way to send an URI in notification for Android Devices, I am facing an issue when trying to send notifications that contain an URI for Android devices. The URI is supposed to be read using Intent.data, but it doesn't seem to work as expected.

mirzemehdi commented 3 months ago

@HoucemK This is implemented in 1.2.1 version of kmpnotifier.

In order to setData for Intent on Android Devices, you just need to put URI value with "URL" key into payloadData (after converting URI toString). If payload data contains value with "URL" key then intent data will be set internally.

Example code:


//Notifier.KEY_URL value is set as "URL" in the library. If payload data contains that key, then its value will be set as intent data.

notifier.notify(
    title = "Title", 
    body = "bodyMessage", 
    payloadData = mapOf(
        Notifier.KEY_URL to "https://github.com/mirzemehdi/KMPNotifier/",
        "extraKey" to "randomValue"
    )
)

For more details, please check PR https://github.com/mirzemehdi/KMPNotifier/pull/60