Push notification not working with FCM
<p>I am trying to get push notifications using Firebase in my Android app. The problem is when the app is in the foreground, I receive the notification and <code>onMessageReceived()</code> is called, however when I am on the background, I don't receive any notification and the <code>onMessageRecieved</code> isn't called.</p>

<p>What am I doing wrong?</p>

<p><strong>Manifest.xml</strong></p>

<pre><code>&lt;service android:name=".notifications.MyFirebaseMessagingService"&gt;
    &lt;intent-filter android:priority="2147483647"&gt;
        &lt;action android:name="com.google.firebase.MESSAGING_EVENT"/&gt;
    &lt;/intent-filter&gt;
&lt;/service&gt;
</code></pre>

<p><strong>MyFirebaseMessagingService.class</strong></p>

<pre><code>public class MyFirebaseMessagingService extends FirebaseMessagingService {

    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("MessagingService", "onCreate Firebase Service");
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        Log.e("MessagingService", "onMessageRecieved");

        String body     = remoteMessage.getData().get("body");

        ooVooSdkSampleShowApp application = (ooVooSdkSampleShowApp) getApplication();

        Intent intent = new Intent(application.getContext(), MainActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(application.getContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

        NotificationCompat.Builder b = new NotificationCompat.Builder(application.getContext());

        b.setAutoCancel(false)
                .setDefaults(Notification.DEFAULT_ALL)
                .setWhen(System.currentTimeMillis())
                .setSmallIcon(R.drawable.image_calendar_red)
                .setContentText(body)
                .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
                .setContentIntent(contentIntent)
                .setContentInfo("Info");

        NotificationManager notificationManager = (NotificationManager) application.getContext().getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, b.build());

    }
}
</code></pre>