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

[question]: How to Capture silent notification data #985

Open
1 task done
sunilsinghchaudhary00 opened this issue Dec 30, 2024 · 0 comments
Open
1 task done

[question]: How to Capture silent notification data #985

sunilsinghchaudhary00 opened this issue Dec 30, 2024 · 0 comments

Comments

@sunilsinghchaudhary00
Copy link

How can we help?

I am trying to capture the silent notification data but unable to do that showing data in log but its onesignal data not my logs
i am getting silent notif data in backgorund onesignal logs

D/OneSignal(28679): [DefaultDispatcher-worker-1] Saving Notification id=d4eed-9291-4a21-aa66-bf11fb6e5eba
D/OneSignal(28679): [DefaultDispatcher-worker-1] Notification saved values: full_data={"google.delivered_priority":"normal","google.sent_time":1735539186317,"google.ttl":2419200,"google.original_priority":"normal","custom":"{"i":"d4eed-9291-4a21-6-bf11fb6e5eba","a":{"body":"{\"description\":\"Testing Silent Notification\"}","click_action":"FLUTTER_NOTIFICATION_CLICK","description":"Testing Silent Notification","title":"Testing Silent Notification"}}","google.product_id":11181503,"from":"38108206621","google.message_id":"0:173553915688%00ae9cb1f9fd7ecd","google.c.sender.id":"381086206621"}

my code is

void initonesignal() {
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.Debug.setAlertLevel(OSLogLevel.none);
OneSignal.consentRequired(false);
OneSignal.initialize("40a574c6-b53f-4277-98bb-e42e96a6028f");
OneSignal.User.pushSubscription.addObserver((state) async {
global.onesignalId = OneSignal.User.pushSubscription.id;
print("Opted Push Subscription Id ${global.onesignalId}");
print("Opt Subscription Token ${OneSignal.User.pushSubscription.token}");
await saveOneSignalId(global.onesignalId!);
});

OneSignal.Notifications.addPermissionObserver((state) {
  log("Has permission $state");
});

OneSignal.Notifications.addClickListener((event) {
  try {
    onSelectNotification(event.notification.additionalData);
  } catch (e) {
    log('Failed to decode handleNotificationData: $e');
  }
});
OneSignal.Notifications.addForegroundWillDisplayListener((event) {
  event.preventDefault();
  event.notification.display();
  log('capture onesignal ${event.notification.additionalData} ');
  showForegroundNotification(event.notification.additionalData);
});

}

custom sound working finee
normal default sound working fine capture data in logs fine
but in silent notif no data is capture in logs pls help anybody have any idea how to do that really helpfull

Code of Conduct

  • I agree to follow this project's Code of Conduct
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

No branches or pull requests

1 participant