onMessageReceived()
onTokenRefresh()
@Override public void onMessageReceived(RemoteMessage remoteMessage) { if (/* Check if data needs to be processed by long running job */ true) { // For long-running tasks (10 seconds or more) use Firebase Job Dispatcher. scheduleJob(); } else { // Handle message within 10 seconds handleNow(); } } /** * Schedule a job using FirebaseJobDispatcher. */ private void scheduleJob() { FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this)); Job myJob = dispatcher.newJobBuilder() .setService(MyJobService.class) .setTag("my-job-tag") .build(); dispatcher.mustSchedule(myJob); } /** * Perform and immediate, but quick, processing of the message. */ private void handleNow() { Log.d(TAG, "Short lived task is done."); }