Skip to content

Commit

Permalink
Merge pull request #6 from Iterable/feature/ITBL-1261-track-push-open…
Browse files Browse the repository at this point in the history
…s-sends

ITBL-1286 Supports messageID for push opens on android.
  • Loading branch information
davidtruong authored Sep 15, 2016
2 parents d2a236a + f257e5a commit 40d6f2f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,14 @@ protected void registerForPush(String iterableAppId, String gcmProjectNumber, bo
* @param campaignId
* @param templateId
*/
protected void trackPushOpen(int campaignId, int templateId) {
protected void trackPushOpen(int campaignId, int templateId, String messageId) {
JSONObject requestJSON = new JSONObject();

try {
requestJSON.put(IterableConstants.KEY_EMAIL, _email);
requestJSON.put(IterableConstants.KEY_CAMPAIGNID, campaignId);
requestJSON.put(IterableConstants.KEY_TEMPLATE_ID, templateId);

requestJSON.put(IterableConstants.KEY_MESSAGE_ID, messageId);
}
catch (JSONException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public final class IterableConstants {
public static final String KEY_RECIPIENT_EMAIL = "recipientEmail";
public static final String KEY_SEND_AT = "sendAt";
public static final String KEY_TEMPLATE_ID = "templateId";
public static final String KEY_MESSAGE_ID = "messageId";
public static final String KEY_TOKEN = "token";
public static final String KEY_PLATFORM = "platform";
public static final String KEY_APPLICATIONNAME = "applicationName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class IterableNotificationData {
private int campaignId;
private int templateId;
private String messageId;
private boolean isGhostPush;

IterableNotificationData(String data){
Expand All @@ -22,6 +23,10 @@ class IterableNotificationData {
templateId = iterableJson.getInt(IterableConstants.KEY_TEMPLATE_ID);
}

if (iterableJson.has(IterableConstants.KEY_MESSAGE_ID)) {
messageId = iterableJson.getString(IterableConstants.KEY_MESSAGE_ID);
}

if (iterableJson.has(IterableConstants.IS_GHOST_PUSH)) {
isGhostPush = iterableJson.getBoolean(IterableConstants.IS_GHOST_PUSH);
}
Expand All @@ -40,6 +45,8 @@ public int getTemplateId()
return this.templateId;
}

public String getMessageId() { return this.messageId; }

public boolean getIsGhostPush()
{
return this.isGhostPush;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void onReceive(Context context, Intent intent) {
IterableNotificationData iterableNotificationData = new IterableNotificationData(iterableDataString);
if (IterableApi.sharedInstance != null) {
IterableApi.sharedInstance.setNotificationData(iterableNotificationData);
IterableApi.sharedInstance.trackPushOpen(iterableNotificationData.getCampaignId(), iterableNotificationData.getTemplateId());
IterableApi.sharedInstance.trackPushOpen(iterableNotificationData.getCampaignId(), iterableNotificationData.getTemplateId(), iterableNotificationData.getMessageId());
}
}
}
Expand Down

0 comments on commit 40d6f2f

Please sign in to comment.