I am receiving notifications from onesignal with actionButtons sent from the service. How can I deal with those buttons and handle their events?
protected boolean onNotificationProcessing(final OSNotificationReceivedResult receivedResult) {
OverrideSettings overrideSettings = new OverrideSettings();
// here I am getting the data sent thtough oneSignal
final JSONObject additionalData = receivedResult.payload.additionalData;
// here I am getting my buttons
final List<OSNotificationPayload.ActionButton> actionButtons = receivedResult.payload.actionButtons;
overrideSettings.extender = new NotificationCompat.Extender() {
@Override
public NotificationCompat.Builder extend(NotificationCompat.Builder builder) {
try {
// Here I am creating my own button and adding it to the notification
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + phoneNumber));
PendingIntent pendingIntentCall = PendingIntent.getActivity(MyService.this, 12345, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.phone_notif,getString(R.string.call),pendingIntentCall);
} catch (Exception e) {
}
return builder;
}
};
return true
}
How can I handle event for the actionButtons that are received from one signal? They appear but when I click on them they act like if I am clicking on a notification ...