OneSignal / OneSignal-Android-SDK

OneSignal is a free push notification service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal. https://onesignal.com
Other
594 stars 368 forks source link

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

Open danielesegato opened 10 months ago

danielesegato commented 10 months ago

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

jennantilla commented 10 months ago

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

danielesegato commented 9 months ago

@jennantilla do you have any update for me?

danielesegato commented 9 months ago

@jennantilla can I please have an update?

jennantilla commented 9 months ago

@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.

danielesegato commented 9 months ago

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.