Skip to content

Commit

Permalink
pushmessage extra data
Browse files Browse the repository at this point in the history
  • Loading branch information
FatihUtkuKara committed Nov 18, 2024
1 parent 84a179f commit 0859940
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
22 changes: 11 additions & 11 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import euromsg.com.euromobileandroid.enums.PushType;
Expand Down Expand Up @@ -48,13 +50,18 @@ public class Message implements Serializable {
private String keyID;
private String email;

private Map<String, Object> extraData = new HashMap<>();

public Message(Context context, @NonNull Map<String, String> bundle) {
try {
for (String key : bundle.keySet()) {

Object value = bundle.get(key);
if (value != null) {
if (isKnownKey(key)) {
params.put(key, value.toString());
} else {
extraData.put(key, value);
}
}
}
date = bundle.get("date");
Expand Down Expand Up @@ -97,6 +104,16 @@ public Message(Context context, @NonNull Map<String, String> bundle) {
}
}

private boolean isKnownKey(String key) {
List<String> knownKeys = Arrays.asList(
"date", "openDate", "status", "mediaUrl", "pushId",
"campaignId", "url", "from", "message", "title",
"sound", "emPushSp", "deliver", "silent", "pushCategory",
"keyID", "email"
);
return knownKeys.contains(key);
}

private void convertJsonStrToElementsArray(Context context, String elementJsonStr) {

JSONArray jsonArr;
Expand Down Expand Up @@ -308,6 +325,10 @@ public String getPushCategory() {
return pushCategory;
}

public Map<String, Object> getExtraData() {
return extraData;
}

public String getKeyID() { return keyID; }

public String getEmail() { return email; }
Expand Down

0 comments on commit 0859940

Please sign in to comment.