Skip to content

Commit

Permalink
NullSafe getNotification when building push notification (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmimeault authored and Jawnnypoo committed Sep 25, 2018
1 parent cbb1b80 commit ff97db3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;

import org.json.JSONException;
Expand Down Expand Up @@ -171,7 +172,12 @@ protected void onPushReceive(Context context, Intent intent) {
context.sendBroadcast(broadcastIntent);
}

Notification notification = getNotification(context, intent).build();
final NotificationCompat.Builder notificationBuilder = getNotification(context, intent);

Notification notification = null;
if (notificationBuilder != null) {
notification = notificationBuilder.build();
}

if (notification != null) {
ParseNotificationManager.getInstance().showNotification(context, notification);
Expand Down Expand Up @@ -383,6 +389,7 @@ protected Intent getDeleteIntent(Bundle extras, String packageName) {
* @return The notification builder to be displayed.
* @see ParsePushBroadcastReceiver#onPushReceive(Context, Intent)
*/
@Nullable
protected NotificationCompat.Builder getNotification(Context context, Intent intent) {
JSONObject pushData = getPushData(intent);
if (pushData == null || (!pushData.has("alert") && !pushData.has("title"))) {
Expand Down

0 comments on commit ff97db3

Please sign in to comment.