[messaging] Handle Android exceptions when message priority not set correctly

This commit is contained in:
Chris Bianca 2018-03-28 09:40:38 +01:00
parent dd940b953b
commit 33cd0b0b13
1 changed files with 9 additions and 5 deletions

View File

@ -35,11 +35,15 @@ public class RNFirebaseMessagingService extends FirebaseMessagingService {
// Broadcast it so it is only available to the RN Application // Broadcast it so it is only available to the RN Application
LocalBroadcastManager.getInstance(this).sendBroadcast(messagingEvent); LocalBroadcastManager.getInstance(this).sendBroadcast(messagingEvent);
} else { } else {
// If the app is in the background we send it to the Headless JS Service try {
Intent headlessIntent = new Intent(this.getApplicationContext(), RNFirebaseBackgroundMessagingService.class); // If the app is in the background we send it to the Headless JS Service
headlessIntent.putExtra("message", message); Intent headlessIntent = new Intent(this.getApplicationContext(), RNFirebaseBackgroundMessagingService.class);
this.getApplicationContext().startService(headlessIntent); headlessIntent.putExtra("message", message);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext()); this.getApplicationContext().startService(headlessIntent);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
} catch (IllegalStateException ex) {
Log.e(TAG, "Background messages will only work if the message priority is set to 'high'", ex);
}
} }
} }
} }