Skip to content

Commit ae0bd36

Browse files
committed
Checks for non-empty data body before rendering notification.
1 parent 1d416ae commit ae0bd36

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,19 @@ static boolean isGhostPush(Bundle extras) {
243243

244244
return isGhostPush;
245245
}
246+
247+
/**
248+
* Returns if the given notification has an empty body
249+
* @param extras
250+
* @return
251+
*/
252+
static boolean isEmptyBody(Bundle extras) {
253+
String notificationBody = "";
254+
if (extras.containsKey(IterableConstants.ITERABLE_DATA_KEY)) {
255+
String iterableData = extras.getString(IterableConstants.ITERABLE_DATA_KEY);
256+
notificationBody = extras.getString(IterableConstants.ITERABLE_DATA_BODY, "");
257+
}
258+
259+
return notificationBody.isEmpty();
260+
}
246261
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void onReceive(Context context, Intent intent) {
4545
private void handlePushReceived(Context context, Intent intent) {
4646
if (intent.hasExtra(IterableConstants.ITERABLE_DATA_KEY)) {
4747
Bundle extras = intent.getExtras();
48-
if (!IterableNotification.isGhostPush(extras)) {
48+
if (!IterableNotification.isGhostPush(extras) && !IterableNotification.isEmptyBody(extras)) {
4949
IterableLogger.d(TAG, "Iterable push received " + extras);
5050
Context appContext = context.getApplicationContext();
5151
PackageManager packageManager = appContext.getPackageManager();

0 commit comments

Comments
 (0)