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

[question]: How to enable Data / Silent notification with no permission on OneSignal 5.x

Open danielesegato opened this issue 2 years ago • 5 comments

How can we help?

On the documentation page for data notifications here: https://documentation.onesignal.com/docs/data-notifications

it say, and I quote:

Android Data Notification Setup The OneSignal SDK is set up to only send data notifications to subscribed users. If you want to target unsubscribed users with data notifications, you will need to follow this workaround.

Data notifications are handled within the NotificationExtenderService - This can be set up to receive data notifications when your app is not running, or to override how notifications are shown in the notification shade.

Except the workaround linked is for iOS SDK.

In OneSignal 4.x there was a method to call (as specified on issue 1538):

OneSignal.unsubscribeWhenNotificationsAreDisabled(false)

that was enough to enable silent notifications when no permission was given.

Can you please update the documentation to add full information on how to manage data notification in Android?

Thank you

Code of Conduct

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

danielesegato avatar Sep 26 '23 12:09 danielesegato

@danielesegato thank you for sharing. We're investigating and will get back to you as soon as possible.

jennantilla avatar Sep 27 '23 20:09 jennantilla

@jennantilla do you have any update for me?

danielesegato avatar Oct 04 '23 07:10 danielesegato

@jennantilla can I please have an update?

danielesegato avatar Oct 17 '23 09:10 danielesegato

@danielesegato thank you for your patience!

We are looking at adding this capability to our API, but currently, the workaround for iOS will work on Android as well:

  1. Create a 2nd OneSignal app to register the push tokens. You can get the token with this method even if the user did not accept notifications.
  2. Use the OneSignal Create Subscription REST API call to register the device to your secondary OneSignal app_id for your silent notifications.

Hope this helps! Let us know if you have any additional questions or concerns.

jennantilla avatar Oct 18 '23 19:10 jennantilla

The 2nd OneSignal app is problematic for us. Do you have an ETA on when this capability will be added?

You had it before the 5.0 SDK.

danielesegato avatar Oct 24 '23 09:10 danielesegato