Firebase Save Notification to DB not working when app is not running
<p>I am handling <code>FCM</code> notifications in my app. in like  </p>

<pre><code>public void onMessageReceived(RemoteMessage remoteMessage) {

        Notification notification = new Notification();
        notification.setTitle(remoteMessage.getNotification().getTitle());
        notification.setDescription(remoteMessage.getNotification().getBody());
        DateFormat simpledateFormat = new SimpleDateFormat("dd/MM/yyyy");
        DateFormat simpleTimeFormat = new SimpleDateFormat("hh:mm");
        Date date = new Date(remoteMessage.getSentTime());

        notification.setTime(simpleTimeFormat.format(date));
        Date date2 = new Date();
        notification.setDate(simpledateFormat.format(date2));
        DatabaseHelper databaseHelper = new    DatabaseHelper(getApplicationContext());
        databaseHelper.saveNotification(notification);

        //Calling method to generate notification
        sendNotification(remoteMessage.getNotification().getBody());
    }
</code></pre>

<p>but when app is not running or in background mode i am not able to save those notifications.</p>

<p>i am using "Regular activity" for processing and display of notifications in app.</p>

<p>as said in <a href="https://developer.android.com/training/notify-user/navigation.html" rel="nofollow">this</a> link</p>

<p>don't know what i am missing.</p>