|
14 | 14 | import com.onesignal.inAppMessages.IInAppMessageWillDismissEvent;
|
15 | 15 | import com.onesignal.inAppMessages.IInAppMessageDidDismissEvent;
|
16 | 16 | import com.onesignal.notifications.INotification;
|
| 17 | +import com.onesignal.notifications.IActionButton; |
17 | 18 | import com.onesignal.notifications.INotificationWillDisplayEvent;
|
18 | 19 | import com.onesignal.notifications.INotificationClickResult;
|
19 | 20 | import com.onesignal.notifications.INotificationClickEvent;
|
@@ -73,12 +74,25 @@ static HashMap<String, Object> convertNotificationToMap(INotification notificati
|
73 | 74 | if (notification.getAdditionalData() != null && notification.getAdditionalData().length() > 0)
|
74 | 75 | hash.put("additionalData", convertJSONObjectToHashMap(notification.getAdditionalData()));
|
75 | 76 | if (notification.getActionButtons() != null) {
|
76 |
| - hash.put("actionButtons", notification.getActionButtons()); |
| 77 | + hash.put("buttons", convertActionButtonsToMap |
| 78 | + (notification.getActionButtons())); |
77 | 79 | }
|
78 | 80 | hash.put("rawPayload", notification.getRawPayload());
|
79 | 81 | return hash;
|
80 | 82 | }
|
81 | 83 |
|
| 84 | + static List<HashMap<String, Object>> convertActionButtonsToMap(List<IActionButton> actionButtons) { |
| 85 | + List<HashMap<String, Object>> convertedList = new ArrayList<HashMap<String, Object>>(); |
| 86 | + for (IActionButton actionButton : actionButtons) { |
| 87 | + HashMap<String, Object> hash = new HashMap<>(); |
| 88 | + hash.put("id", actionButton.getId()); |
| 89 | + hash.put("text", actionButton.getText()); |
| 90 | + hash.put("icon", actionButton.getIcon()); |
| 91 | + convertedList.add(hash); |
| 92 | + } |
| 93 | + return convertedList; |
| 94 | + } |
| 95 | + |
82 | 96 | static HashMap<String, Object> convertNotificationWillDisplayEventToMap(INotificationWillDisplayEvent event) throws JSONException {
|
83 | 97 | HashMap<String, Object> hash = new HashMap<>();
|
84 | 98 | hash.put("notification", convertNotificationToMap(event.getNotification()));
|
|
0 commit comments