[Messaging] Add null check to acquire WakeLock on Android #2092
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The Message module and Notification module will accidentally acquire a
PARTIAL_WAKE_LOCK
by callingHeadlessJsTaskService.acquireWakeLockNow()
, and this lock will always hold if no js tasks to consume it. This will drain off user phones' battery.This happens when you init the Message module without the optional step of adding
RNFirebaseBackgroundMessagingService
to theAndroidManifest.xml
.The
context.startService()
will not throw on unregistered service, it justreturn null
. Adding a null check will handle the cases.On the Notification module, the service is undocumented, should have fewer people using it.
Checklist
Android
iOS
e2e
tests added or updated in /tests/e2e/*Test Plan
Tested on a private production app.
Release Plan
[ANDROID][BUGFIX] [Messaging] - Add null checks to avoid accidentally acquiring wakelocks on Android.
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter