OneSignal-Flutter-SDK icon indicating copy to clipboard operation
OneSignal-Flutter-SDK copied to clipboard

[question]: How can I capture OneSignal notification data when the app is closed (killed state)?

Open denizdurmaz1 opened this issue 1 year ago • 4 comments

Hello I want to capture data and save Hive. When app work and I get notification it work with OneSignal.Notifications.addForegroundWillDisplayListener. But I want to capture data when app closoed and I get data I want to save it to hive I am using Flutter with OneSignal for push notifications. When the app is running (foreground), I can capture notification data using: OneSignal.Notifications.addForegroundWillDisplayListener However, I need to capture notification data even when the app is completely closed (killed state) and save it to Hive. I want to • Receive OneSignal notifications when the app is closed. • Capture notification data (additionalData, collapseKey, etc.). • Save this data to Hive for later use.

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

denizdurmaz1 avatar Feb 06 '25 14:02 denizdurmaz1

any update on this?

find any solution, how to capture background data when app is in killed state

JiyadAhammad avatar Mar 07 '25 19:03 JiyadAhammad

any update on this?

find any solution, how to capture background data when app is in killed state

(https://documentation.onesignal.com/docs/service-extensions) In here there is a way but I didn't implement yet.

denizdurmaz1 avatar Mar 10 '25 06:03 denizdurmaz1

any update on this? find any solution, how to capture background data when app is in killed state

(https://documentation.onesignal.com/docs/service-extensions) In here there is a way but I didn't implement yet.

I implement this and one more thing

//public fuction @pragma("vm:entry-point") Future showNotifications(result) async { }

OneSignal.Notifications.addForegroundWillDisplayListener((event) { showNotifications(event); debugPrint("[OneSignal] Foreground Notification: "); });

Now i am getting notfications but when i click on notification its not opening the app

Numanshakir avatar Mar 22 '25 11:03 Numanshakir

any update on this? find any solution, how to capture background data when app is in killed state

(https://documentation.onesignal.com/docs/service-extensions) In here there is a way but I didn't implement yet.

I implement this and one more thing

//public fuction @pragma("vm:entry-point") Future showNotifications(result) async { }

OneSignal.Notifications.addForegroundWillDisplayListener((event) { showNotifications(event); debugPrint("[OneSignal] Foreground Notification: "); });

Now i am getting notfications but when i click on notification its not opening the app

Do you have any sample code to refer this

JiyadAhammad avatar Mar 22 '25 17:03 JiyadAhammad