title: React-native not receiving push notifications, using Firebase Cloud functions
body: <p><strong>Note: I am testings on a real device</strong></p>
  
  <p>I am trying to send push notifications to my react-native app using Firebase Cloud Functions.</p>
  
  <p>Below is my Cloud Function:</p>
  
  <pre><code>const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  
  admin.initializeApp(functions.config().firebase);
  
  exports.sendNewMessageNotification = functions.database.ref('users').onWrite(event =&gt; {
      const getValuePromise = admin.database()
                                   .ref('users')
                                   .orderByKey()
                                   .limitToLast(1)
                                   .once('value');
  
      return getValuePromise.then(snapshot =&gt; {
  
          const payload = {
              notification: {
                  title: 'Dot notification',
                  body: 'A new user has been added',
              }
          };
  
          return admin.messaging()
                      .sendToTopic('secret-chatroom', payload);
      });
  });
  </code></pre>
  
  <p><strong>The above cloud function is being executed without any error:</strong></p>
  
  <p>Below is my Notification listener in my app:</p>
  
  <pre><code>import * as Type from '../actions/types';
  import FCM, { FCMEvent,
                NotificationType,
                WillPresentNotificationResult,
                RemoteNotificationResult } from 'react-native-fcm';
  import { Platform } from 'react-native';
  import { takeLatest, put, call } from 'redux-saga/effects';
  
  
  function* listenToNotifications() {
      FCM.requestPermissions();
      FCM.getFCMToken()
         .then(token =&gt; {
             console.log(token) //being logged
         });
      FCM.subscribeToTopic('secret-chatroom');
  
      FCM.on(FCMEvent.Notification, async (notif) =&gt; {
          console.log(notif); //not being logged
          alert('Notification recieved');
  
          if (Platform.OS === 'ios') {
              switch (notif._notificationType) {
                  case NotificationType.Remote:
                      notif.finish(RemoteNotificationResult.NewData); //other types available: RemoteNotificationResult.NewData, RemoteNotificationResult.ResultFailed
                      break;
                  case NotificationType.NotificationResponse:
                      notif.finish();
                      break;
                  case NotificationType.WillPresent:
                      notif.finish(WillPresentNotificationResult.All); //other types available: WillPresentNotificationResult.None
                      break;
                }
              }
      });
  
      FCM.on(FCMEvent.RefreshToken, token =&gt; {
          console.log(token);
      });
  }
  
  
  export default function* appNotificationsSaga() {
      yield takeLatest(Type.LISTEN_TO_NOTIFICATIONS, listenToNotifications);
  }
  </code></pre>
  
  <p>FCM.getFCMToken value is being logged, but I am not receiving any notifications when cloud function is executed. Can someone please tell what I am doing wrong?</p>