Skip to content

Commit 81901db

Browse files
authored
Merge pull request #353 from Iterable/MOB-2976-Adding-timestamp-to-Notification
[MOB - 2976] - Adding time stamp to notification
2 parents dda2470 + e3cf8e0 commit 81901db

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

iterableapi/src/androidTest/java/com/iterable/iterableapi/IterableNotificationTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,16 @@ public void testActionButtons() throws Exception {
175175
assertEquals("Silent Action", notification.actions[1].title);
176176
assertEquals("Text input", notification.actions[2].title);
177177
}
178+
179+
@Test
180+
public void testNotificationTimeStamp() throws Exception {
181+
Bundle notificationBundle = new Bundle();
182+
notificationBundle.putString(IterableConstants.ITERABLE_DATA_KEY, itbl2);
183+
notificationBundle.putString(IterableConstants.ITERABLE_DATA_BODY, body);
184+
IterableNotificationBuilder iterableNotification = postNotification(notificationBundle);
185+
StatusBarNotification statusBarNotification = mNotificationManager.getActiveNotifications()[0];
186+
Notification notification = statusBarNotification.getNotification();
187+
//Checking if the notification time is close to system time when received. 5000ms is to compensate with delay that might occur during creation, posting and checking the notification.
188+
assertTrue(System.currentTimeMillis() - notification.when < 5000);
189+
}
178190
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public IterableNotificationBuilder createNotification(Context context, Bundle ex
140140

141141
notificationBuilder
142142
.setSmallIcon(getIconId(context))
143-
.setTicker(applicationName).setWhen(0)
143+
.setTicker(applicationName)
144144
.setAutoCancel(true)
145145
.setContentTitle(title)
146146
.setPriority(NotificationCompat.PRIORITY_HIGH)

0 commit comments

Comments
 (0)