Skip to content

Commit 40d6f2f

Browse files
authored
Merge pull request #6 from Iterable/feature/ITBL-1261-track-push-opens-sends
ITBL-1286 Supports messageID for push opens on android.
2 parents d2a236a + f257e5a commit 40d6f2f

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,14 @@ protected void registerForPush(String iterableAppId, String gcmProjectNumber, bo
369369
* @param campaignId
370370
* @param templateId
371371
*/
372-
protected void trackPushOpen(int campaignId, int templateId) {
372+
protected void trackPushOpen(int campaignId, int templateId, String messageId) {
373373
JSONObject requestJSON = new JSONObject();
374374

375375
try {
376376
requestJSON.put(IterableConstants.KEY_EMAIL, _email);
377377
requestJSON.put(IterableConstants.KEY_CAMPAIGNID, campaignId);
378378
requestJSON.put(IterableConstants.KEY_TEMPLATE_ID, templateId);
379-
379+
requestJSON.put(IterableConstants.KEY_MESSAGE_ID, messageId);
380380
}
381381
catch (JSONException e) {
382382
e.printStackTrace();

iterableapi/src/main/java/com/iterable/iterableapi/IterableConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public final class IterableConstants {
2020
public static final String KEY_RECIPIENT_EMAIL = "recipientEmail";
2121
public static final String KEY_SEND_AT = "sendAt";
2222
public static final String KEY_TEMPLATE_ID = "templateId";
23+
public static final String KEY_MESSAGE_ID = "messageId";
2324
public static final String KEY_TOKEN = "token";
2425
public static final String KEY_PLATFORM = "platform";
2526
public static final String KEY_APPLICATIONNAME = "applicationName";

iterableapi/src/main/java/com/iterable/iterableapi/IterableNotificationData.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class IterableNotificationData {
1010
private int campaignId;
1111
private int templateId;
12+
private String messageId;
1213
private boolean isGhostPush;
1314

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

26+
if (iterableJson.has(IterableConstants.KEY_MESSAGE_ID)) {
27+
messageId = iterableJson.getString(IterableConstants.KEY_MESSAGE_ID);
28+
}
29+
2530
if (iterableJson.has(IterableConstants.IS_GHOST_PUSH)) {
2631
isGhostPush = iterableJson.getBoolean(IterableConstants.IS_GHOST_PUSH);
2732
}
@@ -40,6 +45,8 @@ public int getTemplateId()
4045
return this.templateId;
4146
}
4247

48+
public String getMessageId() { return this.messageId; }
49+
4350
public boolean getIsGhostPush()
4451
{
4552
return this.isGhostPush;

iterableapi/src/main/java/com/iterable/iterableapi/IterablePushOpenReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void onReceive(Context context, Intent intent) {
3232
IterableNotificationData iterableNotificationData = new IterableNotificationData(iterableDataString);
3333
if (IterableApi.sharedInstance != null) {
3434
IterableApi.sharedInstance.setNotificationData(iterableNotificationData);
35-
IterableApi.sharedInstance.trackPushOpen(iterableNotificationData.getCampaignId(), iterableNotificationData.getTemplateId());
35+
IterableApi.sharedInstance.trackPushOpen(iterableNotificationData.getCampaignId(), iterableNotificationData.getTemplateId(), iterableNotificationData.getMessageId());
3636
}
3737
}
3838
}

0 commit comments

Comments
 (0)