Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android deeplink support (send notifications with URI on Android devices) #60

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

mirzemehdi
Copy link
Owner

@mirzemehdi mirzemehdi commented Aug 7, 2024

Solves: #52

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"
    )
)

@mirzemehdi mirzemehdi merged commit 66c8506 into rel_v1.2.1 Aug 7, 2024
@mirzemehdi mirzemehdi deleted the android_deeplink_support branch August 7, 2024 23:04
@mirzemehdi mirzemehdi linked an issue Aug 7, 2024 that may be closed by this pull request
@estreteca
Copy link

How can I capture the notification when the app is closed?, and thus be able to refresh cache for example

@RomanMarinov
Copy link

RomanMarinov commented Oct 13, 2024

How to catch a push notification on iOS if the application was previously destroyed? I want to open another event

@akinkhov
Copy link

where to process a push if the application is closed?

@AntonLihtar
Copy link

NotifierManager.addListener does not work when the application is killed

@Maandraj
Copy link

Yes, the question arose what does it do if the application is killed

@ubarua123
Copy link

This library does not work when the app is killed/closed. Only works when it's in foreground. Took me a while to figure this out.

@mirzemehdi
Copy link
Owner Author

@ubarua123 that's not true completely. Well both yes, and no

On Android this is how it works:

If you send both notification and data type message, or just notification type message, then you are right when app is in background listener will not be called.

If you want listener to be called when app is in background or killed, you need to send only data type message, that way listener will be called when app is in background. This is how it works from Firebase side. When you try to test push notificaiton from firebase console it will attach notification type message. So solution would be sending push notification using api, and sending only data type message.

You can use this file to test your notification and in the script remove notification title, and body part and send only data type message:
https://github.com/mirzemehdi/KMPNotifier/blob/main/firebase_push_notification_sender.py

Related stackoverflow issue: https://stackoverflow.com/questions/37358462/firebase-onmessagereceived-not-called-when-app-in-background

From ios side I still need to investigate a bit : but you can check comments in this issue as well: #24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to send notifications with URI on Android devices
7 participants