Skip to content

Commit ff97db3

Browse files
mmimeaultJawnnypoo
authored andcommitted
NullSafe getNotification when building push notification (#889)
1 parent cbb1b80 commit ff97db3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

parse/src/main/java/com/parse/ParsePushBroadcastReceiver.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.net.Uri;
2222
import android.os.Build;
2323
import android.os.Bundle;
24+
import android.support.annotation.Nullable;
2425
import android.support.v4.app.NotificationCompat;
2526

2627
import org.json.JSONException;
@@ -171,7 +172,12 @@ protected void onPushReceive(Context context, Intent intent) {
171172
context.sendBroadcast(broadcastIntent);
172173
}
173174

174-
Notification notification = getNotification(context, intent).build();
175+
final NotificationCompat.Builder notificationBuilder = getNotification(context, intent);
176+
177+
Notification notification = null;
178+
if (notificationBuilder != null) {
179+
notification = notificationBuilder.build();
180+
}
175181

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

0 commit comments

Comments
 (0)