From d83667682dc8d815b2834aa3a73ae22bf9ebac49 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 1 Nov 2019 06:54:32 +0100 Subject: [PATCH] handle FCM data-only messages --- app | 2 +- .../lbry/browser/LbrynetMessagingService.java | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app b/app index 59159195..a127e14a 160000 --- a/app +++ b/app @@ -1 +1 @@ -Subproject commit 5915919560f641d16da26b9dc06bd1a1f122585c +Subproject commit a127e14a0f6828d2d5d165d05f75afc315700138 diff --git a/src/main/java/io/lbry/browser/LbrynetMessagingService.java b/src/main/java/io/lbry/browser/LbrynetMessagingService.java index 94745fe8..f3d32319 100644 --- a/src/main/java/io/lbry/browser/LbrynetMessagingService.java +++ b/src/main/java/io/lbry/browser/LbrynetMessagingService.java @@ -41,19 +41,14 @@ public class LbrynetMessagingService extends FirebaseMessagingService { Log.d(TAG, "From: " + remoteMessage.getFrom()); Map payload = remoteMessage.getData(); - String type = null; - String url = null; if (payload != null) { - type = payload.get("type"); - url = payload.get("target"); - } - - if (type != null && getEnabledTypes().indexOf(type) > -1) { - // Check if message contains a notification payload. - RemoteMessage.Notification remoteNotification = remoteMessage.getNotification(); - if (remoteNotification != null) { - Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); - sendNotification(remoteNotification.getTitle(), remoteNotification.getBody(), type, url); + String type = payload.get("type"); + String url = payload.get("target"); + String title = payload.get("title"); + String body = payload.get("body"); + if (type != null && getEnabledTypes().indexOf(type) > -1 && body != null && body.trim().length() > 0) { + Log.d(TAG, "Message Notification Body: " + body); + sendNotification(title, body, type, url); } } }