Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Messaging] Add null check to acquire WakeLock on Android #2092

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
}
}