title: Unable to receive Push Notification from firebase console (React Native Android)
body: <p>I am trying to fix this from the last 5 days but I am not sure what I am doing wrong. I have followed the instructions mentioned in <a href="https://www.youtube.com/watch?v=dyAwv9HLS60" rel="nofollow noreferrer">https://www.youtube.com/watch?v=dyAwv9HLS60</a>. But unable to receive any notification from the firebase console. Although when I try to send test notification from with device token. I receive a notification on my device. I am not sure what I am doing wrong. First, I thought it is because I have enabled the Hermes engine but even after setting it to false I am not able to receive Notifications.</p>
  <p>Environment</p>
  <ul>
  <li>React-Native 0.63.2</li>
  <li>&quot;react-native-push-notification&quot;: &quot;^5.1.1&quot;</li>
  <li>&quot;@react-native-firebase/app&quot;: &quot;^8.4.2&quot;,</li>
  <li>&quot;@react-native-firebase/messaging&quot;: &quot;^7.8.6&quot;,</li>
  </ul>
  <p>My app/build.gradle</p>
  <pre><code>apply plugin: &quot;com.android.application&quot;
  apply plugin: 'com.google.gms.google-services'
  
  import com.android.build.OutputFile
  project.ext.react = [
  enableHermes: true,  // clean and rebuild if changing
  ]
  
  apply from: &quot;../../node_modules/react-native/react.gradle&quot;
  def enableSeparateBuildPerCPUArchitecture = false
  
  /**
  * Run Proguard to shrink the Java bytecode in release builds.
  */
  def enableProguardInReleaseBuilds = false
  
  /**
  * The preferred build flavor of JavaScriptCore.
  *
  * For example, to use the international variant, you can use:
  * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
  *
  * The international variant includes ICU i18n library and necessary data
  * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
  * give correct results when using with locales other than en-US.  Note that
  * this variant is about 6MiB larger per architecture than default.
  */
  def jscFlavor = 'org.webkit:android-jsc:+'
  
  /**
  * Whether to enable the Hermes VM.
  *
  * This should be set on project.ext.react and mirrored here.  If it is not set
  * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  * and the benefits of using Hermes will therefore be sharply reduced.
  */
  def enableHermes = project.ext.react.get(&quot;enableHermes&quot;, false);
  
  android {
      compileSdkVersion rootProject.ext.compileSdkVersion
  
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
  
      defaultConfig {
          multiDexEnabled true
          applicationId &quot;com.fatemicreators.fmbamravati&quot;
          minSdkVersion rootProject.ext.minSdkVersion
          targetSdkVersion rootProject.ext.targetSdkVersion
          versionCode 1
          versionName &quot;1.0&quot;
      }
      splits {
          abi {
              reset()
              enable enableSeparateBuildPerCPUArchitecture
              universalApk false  // If true, also generate a universal APK
              include &quot;armeabi-v7a&quot;, &quot;x86&quot;, &quot;arm64-v8a&quot;, &quot;x86_64&quot;
          }
      }
      signingConfigs {
          debug {
              storeFile file('debug.keystore')
              storePassword 'android'
              keyAlias 'androiddebugkey'
              keyPassword 'android'
          }
      }
      buildTypes {
          debug {
              signingConfig signingConfigs.debug
          }
          release {
              // Caution! In production, you need to generate your own keystore file.
              // see https://reactnative.dev/docs/signed-apk-android.
              signingConfig signingConfigs.debug
              minifyEnabled enableProguardInReleaseBuilds
              proguardFiles getDefaultProguardFile(&quot;proguard-android.txt&quot;), &quot;proguard-rules.pro&quot;
          }
      }
  
      // applicationVariants are e.g. debug, release
      applicationVariants.all { variant -&gt;
          variant.outputs.each { output -&gt;
              // For each separate APK per architecture, set a unique version code as described here:
              // https://developer.android.com/studio/build/configure-apk-splits.html
              def versionCodes = [&quot;armeabi-v7a&quot;: 1, &quot;x86&quot;: 2, &quot;arm64-v8a&quot;: 3, &quot;x86_64&quot;: 4]
              def abi = output.getFilter(OutputFile.ABI)
              if (abi != null) {  // null for the universal-debug, universal-release variants
                  output.versionCodeOverride =
                          versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
              }
  
          }
      }
  }
  
  dependencies {
      implementation fileTree(dir: &quot;libs&quot;, include: [&quot;*.jar&quot;])
      //noinspection GradleDynamicVersion
      implementation &quot;com.facebook.react:react-native:+&quot;  // From node_modules
  
      implementation 'com.google.firebase:firebase-analytics:17.5.0'
  
      implementation 'com.android.support:multidex:1.0.3'
  
      implementation &quot;androidx.swiperefreshlayout:swiperefreshlayout:1.0.0&quot;
  
      debugImplementation(&quot;com.facebook.flipper:flipper:${FLIPPER_VERSION}&quot;) {
      exclude group:'com.facebook.fbjni'
      }
  
      debugImplementation(&quot;com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}&quot;) {
          exclude group:'com.facebook.flipper'
          exclude group:'com.squareup.okhttp3', module:'okhttp'
      }
  
      debugImplementation(&quot;com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}&quot;) {
          exclude group:'com.facebook.flipper'
      }
  
      if (enableHermes) {
          def hermesPath = &quot;../../node_modules/hermes-engine/android/&quot;;
          debugImplementation files(hermesPath + &quot;hermes-debug.aar&quot;)
          releaseImplementation files(hermesPath + &quot;hermes-release.aar&quot;)
      } else {
          implementation jscFlavor
      }
  }
  
  // Run this once to be able to run the application with BUCK
  // puts all compile dependencies into folder libs for BUCK to use
  task copyDownloadableDepsToLibs(type: Copy) {
      from configurations.compile
      into 'libs'
  }
  
  apply from: file(&quot;../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle&quot;); applyNativeModulesAppBuildGradle(project)
  </code></pre>
  <p>My FCMService.js</p>
  <pre><code>import messaging from '@react-native-firebase/messaging'
  import { Platform } from 'react-native';
  
  class FCMService {
  
  register = (onRegister, onNotification, onOpenNotification) =&gt; {
      this.checkPermission(onRegister)
      this.createNotificationListeners(onRegister, onNotification, onOpenNotification)
  }
  
  registerAppWithFCM = async () =&gt; {
      if (Platform.OS === 'ios') {
          await messaging().registerDeviceForRemoteMessages();
          await messaging().setAutoInitEnabled(true)
      }
  }
  
  checkPermission = (onRegister) =&gt; {
      messaging().hasPermission()
          .then(enabled =&gt; {
              if (enabled) {
                  // User has permissions
                  this.getToken(onRegister)
              } else {
                  // User doesn't have permission
                  this.requestPermission(onRegister)
              }
          }).catch(error =&gt; {
              console.log(&quot;[FCMService] Permission rejected &quot;, error)
          })
  }
  
  getToken = (onRegister) =&gt; {
      messaging().getToken()
          .then(fcmToken =&gt; {
              if (fcmToken) {
                  onRegister(fcmToken)
              } else {
                  console.log(&quot;[FCMService] User does not have a device token&quot;)
              }
          }).catch(error =&gt; {
              console.log(&quot;[FCMService] getToken rejected &quot;, error)
          })
  }
  
  requestPermission = (onRegister) =&gt; {
      messaging().requestPermission()
          .then(() =&gt; {
              this.getToken(onRegister)
          }).catch(error =&gt; {
              console.log(&quot;[FCMService] Request Permission rejected &quot;, error)
          })
  }
  
  deleteToken = () =&gt; {
      console.log(&quot;[FCMService] deleteToken &quot;)
      messaging().deleteToken()
          .catch(error =&gt; {
              console.log(&quot;[FCMService] Delete token error &quot;, error)
          })
  }
  
  createNotificationListeners = (onRegister, onNotification, onOpenNotification) =&gt; {
  
      // When the application is running, but in the background
      messaging()
          .onNotificationOpenedApp(remoteMessage =&gt; {
              console.log('[FCMService] onNotificationOpenedApp Notification caused app to open from background state:', remoteMessage)
              if (remoteMessage) {
                  const notification = remoteMessage.notification
                  onOpenNotification(notification)
                  // this.removeDeliveredNotification(notification.notificationId)
              }
          });
  
      // When the application is opened from a quit state.
      messaging()
          .getInitialNotification()
          .then(remoteMessage =&gt; {
              console.log('[FCMService] getInitialNotification Notification caused app to open from quit state:', remoteMessage)
  
              if (remoteMessage) {
                  const notification = remoteMessage.notification
                  onOpenNotification(notification)
                  //  this.removeDeliveredNotification(notification.notificationId)
              }
          });
  
      // Foreground state messages
      this.messageListener = messaging().onMessage(async remoteMessage =&gt; {
          console.log('[FCMService] A new FCM message arrived!', remoteMessage);
          if (remoteMessage) {
              let notification = null
              if (Platform.OS === 'ios') {
                  notification = remoteMessage.data.notification
              } else {
                  notification = remoteMessage.notification
              }
              onNotification(notification)
          }
      });
  
      // Triggered when have new token
      messaging().onTokenRefresh(fcmToken =&gt; {
          console.log(&quot;[FCMService] New token refresh: &quot;, fcmToken)
          onRegister(fcmToken)
      })
  
  }
  
  unRegister = () =&gt; {
      this.messageListener()
  }
  }
  
  export const fcmService = new FCMService()
  </code></pre>