OneSignal-Android-SDK
OneSignal-Android-SDK copied to clipboard
[Looking for Feedback] OneSignal SDK v5.0.0-beta2 Released!
In this major version alpha release for the OneSignal SDK, we are making a significant shift from a device-centered model to a user-centered model. A user-centered model allows for more powerful omni-channel integrations within the OneSignal platform.
For information please see the migration guide.
🚧 Alpha release. It is not recommended to use in production. 🚧
Please post any feedback related to the alpha under this issue.
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
The v5.0.0-beta1 has been released. For information please see the migration guide.
🚧 Beta release. It is not recommended to use in production. 🚧
Linking #1735 as a question thread for reference.
The v5.0.0-beta2 has been released. For more information please see the migration guide.
Is Notification Service Extension still possible in 5.0.0? Unable to find OSRemoteNotificationReceivedHandler interface from 4.8.6. Nothing about it in migration guide as well.
what is the alternative for OSNotificationOpenedHandler from 4.8.6 in 5.0.0?
@Popda
Thanks for the feedback!
Is Notification Service Extension still possible in 5.0.0? Unable to find OSRemoteNotificationReceivedHandler interface from 4.8.6. Nothing about it in migration guide as well.
Yes, the Notification Service Extension is still available in 5.0.0. Things have been renamed and OSRemoteNotificationReceivedHandler
has been changed.
In 5.0.0, the code should look something like this:
import com.onesignal.notifications.IDisplayableMutableNotification;
import com.onesignal.notifications.INotificationReceivedEvent;
import com.onesignal.notifications.INotificationServiceExtension;
public class NotificationServiceExtension implements INotificationServiceExtension {
@Override
public void onNotificationReceived(INotificationReceivedEvent event) {
// Here is some code for example :
Log.v(Tag.LOG_TAG, "IRemoteNotificationReceivedHandler fired" + " with INotificationReceivedEvent: " + event.toString());
IDisplayableMutableNotification notification = event.getNotification();
notification.setExtender(builder -> builder.setColor(event.getContext().getResources().getColor(R.color.colorPrimary)));
}
}
Here is an example Notification Service Extension we use in our Android example project: https://github.com/OneSignal/OneSignal-Android-SDK/blob/user-model/main/Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/notification/NotificationServiceExtension.java
We haven’t updated the Notification Service Extension Android documentation yet, thanks for letting us know!
what is the alternative for OSNotificationOpenedHandler from 4.8.6 in 5.0.0?
It has been changed to ClickListener
, you can read more about it in our docs here and in the migration guide here
Let us know if you have any questions!
There should be a table with old and replaced methods/interfaces. That's not really a migration guide. Else it is hard for big projects to search for all new methods/interfaces
Hi, how to get additional data from push message ? I have a code, but what method should I use to get additional payload from "event" ?
OneSignal.getNotifications().addClickListener(event ->
{
event. ?? // how to get additional data(key-value pairs) from this event
});
p.s. oh... is this an answer event.getNotification().getAdditionalData()
?
Where did
OneSignal.unsubscribeWhenNotificationsAreDisabled(false)
go? (see #1538)
Isn't i possible to have silent notification without permission anymore with 5.x? (currently trying with 5.0.2) That's a major flow... (see #1853)
There should be a table with old and replaced methods/interfaces.
That's a good idea, since so much has changed. We will look into adding this, since people will still be upgrading for a while yet.
Hi, how to get additional data from push message ? I have a code, but what method should I use to get additional payload from "event" ?
OneSignal.getNotifications().addClickListener(event ->
{
event. ?? // how to get additional data(key-value pairs) from this event
});
p.s. oh... is this an answer
event.getNotification().getAdditionalData()
?
Correct!
Isn't i possible to have silent notification without permission anymore with 5.x? (currently trying with 5.0.2) That's a major flow... (see https://github.com/OneSignal/OneSignal-Android-SDK/issues/1853)
I reopened issue #1853 so the request can be tracked there.
Closing and locking this issue as the v5.x.x SDK is no longer in beta. Please create a new issue if you have any other topics.