From 44ce6123f7449a7d556d3cf3299222aba46737b8 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Tue, 30 Apr 2019 17:16:56 +0800 Subject: [PATCH 1/2] Add null check for RNFirebaseBackgroundMessagingService --- .../firebase/messaging/RNFirebaseMessagingService.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java index b99e337911..bac913b6dc 100644 --- a/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java +++ b/android/src/main/java/io/invertase/firebase/messaging/RNFirebaseMessagingService.java @@ -1,6 +1,7 @@ package io.invertase.firebase.messaging; import android.content.Intent; +import android.content.ComponentName; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; @@ -58,10 +59,10 @@ public void onMessageReceived(RemoteMessage message) { RNFirebaseBackgroundMessagingService.class ); headlessIntent.putExtra("message", message); - this - .getApplicationContext() - .startService(headlessIntent); - HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext()); + ComponentName name = this.getApplicationContext().startService(headlessIntent); + if (name != null) { + HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext()); + } } catch (IllegalStateException ex) { Log.e( TAG, From b420a8f02debd0c3413624de2270132d3ab10253 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Tue, 30 Apr 2019 17:22:13 +0800 Subject: [PATCH 2/2] Add null check for RNFirebaseBackgroundNotificationActionsService --- .../RNFirebaseBackgroundNotificationActionReceiver.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java index 67379203ce..53defb1f9c 100644 --- a/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java +++ b/android/src/main/java/io/invertase/firebase/notifications/RNFirebaseBackgroundNotificationActionReceiver.java @@ -3,6 +3,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.ComponentName; import android.os.Bundle; import android.support.v4.app.RemoteInput; @@ -62,8 +63,10 @@ public void onReceive(Context context, Intent intent) { if (remoteInput != null) { serviceIntent.putExtra("results", remoteInput); } - context.startService(serviceIntent); - HeadlessJsTaskService.acquireWakeLockNow(context); + ComponentName name = context.startService(serviceIntent); + if (name != null) { + HeadlessJsTaskService.acquireWakeLockNow(context); + } } } }