From 3c59786481e2ed4505ea58da64d731ec40c19ce4 Mon Sep 17 00:00:00 2001 From: Nan Date: Mon, 18 Oct 2021 13:28:44 -0700 Subject: [PATCH] Add `toJSONObject` method to `OSInAppMessage` - Add this method for the wrappers to use - `OSInAppMessageInternal` extends `OSInAppMessage` so its `toJSONObject` method must be `public` because we can't override to reduce visibility --- .../main/java/com/onesignal/OSInAppMessage.java | 17 +++++++++++++++++ .../com/onesignal/OSInAppMessageInternal.java | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java b/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java index c2f3d6ffa3..d7d0d0d13a 100644 --- a/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java +++ b/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java @@ -29,8 +29,13 @@ import androidx.annotation.NonNull; +import org.json.JSONException; +import org.json.JSONObject; + public class OSInAppMessage { + public static final String IAM_ID = "messageId"; + /** * The unique identifier for this in-app message */ @@ -46,4 +51,16 @@ public String getMessageId() { return messageId; } + public JSONObject toJSONObject() { + JSONObject mainObj = new JSONObject(); + try { + mainObj.put(IAM_ID, messageId); + } + catch(JSONException e) { + e.printStackTrace(); + } + + return mainObj; + } + } diff --git a/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageInternal.java b/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageInternal.java index 0d18e58653..1204cffe23 100644 --- a/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageInternal.java +++ b/OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageInternal.java @@ -145,7 +145,8 @@ protected ArrayList> parseTriggerJson(JSONArray triggersJso return parsedTriggers; } - JSONObject toJSONObject() { + @Override + public JSONObject toJSONObject() { JSONObject json = new JSONObject(); try {