Skip to content

Commit 3c59786

Browse files
committed
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
1 parent 2dd1948 commit 3c59786

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929

3030
import androidx.annotation.NonNull;
3131

32+
import org.json.JSONException;
33+
import org.json.JSONObject;
34+
3235
public class OSInAppMessage {
3336

37+
public static final String IAM_ID = "messageId";
38+
3439
/**
3540
* The unique identifier for this in-app message
3641
*/
@@ -46,4 +51,16 @@ public String getMessageId() {
4651
return messageId;
4752
}
4853

54+
public JSONObject toJSONObject() {
55+
JSONObject mainObj = new JSONObject();
56+
try {
57+
mainObj.put(IAM_ID, messageId);
58+
}
59+
catch(JSONException e) {
60+
e.printStackTrace();
61+
}
62+
63+
return mainObj;
64+
}
65+
4966
}

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageInternal.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ protected ArrayList<ArrayList<OSTrigger>> parseTriggerJson(JSONArray triggersJso
145145
return parsedTriggers;
146146
}
147147

148-
JSONObject toJSONObject() {
148+
@Override
149+
public JSONObject toJSONObject() {
149150
JSONObject json = new JSONObject();
150151

151152
try {

0 commit comments

Comments
 (0)