[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
LocalBroadcastManager.getInstance(this).sendBroadcast(messagingEvent);
} else {
// If the app is in the background we send it to the Headless JS Service
Intent headlessIntent = new Intent(this.getApplicationContext(), RNFirebaseBackgroundMessagingService.class);
headlessIntent.putExtra("message", message);
this.getApplicationContext().startService(headlessIntent);
HeadlessJsTaskService.acquireWakeLockNow(this.getApplicationContext());
try {
// If the app is in the background we send it to the Headless JS Service
Intent headlessIntent = new Intent(this.getApplicationContext(), RNFirebaseBackgroundMessagingService.class);
headlessIntent.putExtra("message", message);
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);
}
}
}
}