Describe your issue here
Click To Expand
#### `package.json`:
{
"name": "UOMI",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/async-storage": "^1.8.1",
"@react-native-community/datetimepicker": "^2.2.3",
"@react-native-community/netinfo": "^5.6.2",
"@react-native-community/push-notification-ios": "^1.2.0",
"@react-native-firebase/app": "6",
"@react-native-firebase/messaging": "6",
"axios": "^0.19.2",
"currency-symbol-map": "^4.0.4",
"model": "^6.0.1",
"moment": "^2.24.0",
"moment-timezone": "^0.5.28",
"qs": "^6.9.1",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-ad-consent": "https://github.com/ankit-silversky/react-native-ad-consent.git",
"react-native-admob": "^2.0.0-beta.6",
"react-native-country-picker-modal": "https://github.com/ankit-silversky/country--picker-modal.git",
"react-native-device-info": "^5.5.3",
"react-native-fbsdk": "^1.1.1",
"react-native-gesture-handler": "^1.5.2",
"react-native-localize": "^1.3.3",
"react-native-material-dropdown": "^0.11.1",
"react-native-material-textfield": "^0.16.1",
"react-native-md5": "^1.0.0",
"react-native-modal": "^11.5.3",
"react-native-modal-datetime-picker": "^8.1.2",
"react-native-modal-loader": "^1.3.0",
"react-native-popup-dialog": "^0.18.3",
"react-native-push-notification": "^3.4.0",
"react-native-reanimated": "^1.4.0",
"react-native-root-toast": "^3.2.0",
"react-native-safe-area-context": "^0.6.1",
"react-native-safe-area-view": "^1.0.0",
"react-native-screens": "^2.0.0-beta.2",
"react-native-webview": "^8.0.6",
"react-navigation": "^4.0.10",
"react-navigation-hooks": "^1.1.0",
"react-navigation-stack": "^1.10.3",
"react-redux": "^7.1.3",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.8",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/runtime": "^7.7.7",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.8.0",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.57.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
#### `firebase.json` for react-native-firebase v6:
{
"react-native": {
"messaging_android_notification_channel_id": "high-priority"
}
}
### iOS
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:
# N/A
#### `AppDelegate.m`:
// N/A
Click To Expand
#### Have you converted to AndroidX? - [ ] my application is an AndroidX application? - [x] I am using `android/gradle.settings` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`:
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
googlePlayServicesVersion = "17.0.0"
}
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
//classpath 'com.google.gms:google-services:4.3.2'
// classpath 'com.google.gms:google-services:4.2.0'
classpath('com.google.gms:google-services:4.3.3')
// classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta01'
classpath 'io.fabric.tools:gradle:1.31.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
#### `android/app/build.gradle`:
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
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("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.uomi"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// 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 = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 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 project(':react-native-device-info')
implementation project(':react-native-ad-consent')
implementation project(':react-native-admob')
implementation project(':react-native-webview')
implementation project(':react-native-localize')
implementation project(':react-native-fbsdk')
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+"
implementation 'com.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
implementation "com.google.firebase:firebase-core:${googlePlayServicesVersion}"
// implementation "com.google.android.gms:play-services-base:17.2.1"
// implementation "com.google.firebase:firebase-core:17.2.2"
//implementation 'com.google.firebase:firebase-messaging:20.1.7'
// implementation "com.google.firebase:firebase-messaging:20.1.0"// From node_modules
implementation 'com.facebook.android:facebook-login:[5,6)'
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
implementation 'com.google.android.gms:play-services-ads:18.3.0'
// Add the Firebase Crashlytics dependency.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
// Add the Firebase SDK for Crashlytics.
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} 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("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = true } // here!!
apply plugin: 'io.fabric'
//apply plugin: 'com.google.firebase.crashlytics'
#### `android/settings.gradle`:
rootProject.name = 'UOMI'
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-ad-consent'
project(':react-native-ad-consent').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-ad-consent/android')
include ':react-native-admob'
project(':react-native-admob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-admob/android')
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
include ':react-native-localize'
project(':react-native-localize').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-localize/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
#### `MainApplication.java`:
package com.uomi;
import android.app.Application;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.util.Base64;
import android.util.Log;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.soloader.SoLoader;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.reactcommunity.rndatetimepicker.RNDateTimePickerPackage;
import com.reactcommunity.rnlocalize.RNLocalizePackage;
import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
import com.reactnativecommunity.netinfo.NetInfoPackage;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.sbugert.rnadmob.RNAdMobPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.swmansion.reanimated.ReanimatedPackage;
import com.th3rdwave.safeareacontext.SafeAreaContextPackage;
import java.lang.reflect.InvocationTargetException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
import de.bnass.RNAdConsent.RNAdConsentPackage;
// import io.invertase.firebase.RNFirebasePackage;
// import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
// import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
// import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// return Arrays.<ReactPackage>asList(new MainReactPackage(),
// new RNDeviceInfo(),
// new AsyncStoragePackage(),
// new NetInfoPackage(),
// new RNDateTimePickerPackage(),
// new RNAdConsentPackage(),
// new RNAdMobPackage(),
// new RNCWebViewPackage(),
// new RNLocalizePackage(), new RNGestureHandlerPackage(),
// new SafeAreaContextPackage(), new ReanimatedPackage(),
// // new RNFirebasePackage(),
// // new RNFirebaseNotificationsPackage(),
// // new RNFirebaseMessagingPackage(),
// new FBSDKPackage()
// // new RNFirebaseCrashlyticsPackage()
// );
// packages.add(new RNDeviceInfo());
// packages.add(new AsyncStoragePackage());
// packages.add(new NetInfoPackage());
// packages.add(new RNDateTimePickerPackage());
// packages.add(new RNAdConsentPackage());
// packages.add(new RNAdMobPackage());
// packages.add(new RNCWebViewPackage());
// packages.add(new RNLocalizePackage());
// packages.add(new RNGestureHandlerPackage());
// packages.add(new SafeAreaContextPackage());
// packages.add(new ReanimatedPackage());
// packages.add(new FBSDKPackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
printHashKey(this);
}
public static void printHashKey(Context pContext) {
try {
PackageInfo info = pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String hashKey = new String(Base64.encode(md.digest(), 0));
Log.e("hash>>", "printHashKey() Hash Key: " + hashKey);
}
} catch (NoSuchAlgorithmException e) {
Log.e("TAG>>", "printHashKey()", e);
} catch (Exception e) {
Log.e("TAG>>", "printHashKey()", e);
}
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.uomi">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:screenOrientation="portrait"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- RNFirebaseMessagingService-->
<service android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<!-- RNFirebaseBackgroundMessagingService-->
<service android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@mipmap/ic_launcher" />
<!-- <meta-data-->
<!-- android:name="com.google.firebase.messaging.default_notification_color"-->
<!-- android:resource="#fff" />-->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>
</manifest>
Click To Expand
**`react-native info` output:**
info Fetching system and libraries information...
System:
OS: macOS 10.15.2
CPU: (4) x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
Memory: 48.31 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 13.6.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 26, 27, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.2.1/11B53 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
npmGlobalPackages:
react-native-cli: 2.0.1
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [x] Android
- [ ] **iOS** but have not tested behavior on Android
- [ ] **Android** but have not tested behavior on iOS
- [ ] Both
- **`react-native-firebase` version you're using that has this issue:**
- 6.7.1
- **`Firebase` module(s) you're using that has the issue:**
- Messaging
- **Are you using `TypeScript`?**
- N
React Native Firebase and Invertase on Twitter for updates on the library.We've seen an 80% drop in the number of people receiving Push Notifications on Android since upgrading from 6.3.3 -> 6.4.0
Is this a known issue at all or do I need to dig in to my configuration? I know there were some breaking changes between these versions but we followed all the suggestions
Not receiving push notification in android when an app is in background doesn't really help us help you.
We need to see your JS code, how/where/when are you registering your background handler, etc - can you provide more context
We've seen an 80% drop in the number of people receiving Push Notifications on Android since upgrading from
6.3.3->6.4.0Is this a known issue at all or do I need to dig in to my configuration? I know there were some breaking changes between these versions but we followed all the suggestions
Same as above, could do with some more context please, thanks
yes i can provide more context, and i am not registering the background handler (setBackgroundMessageHandler) because i do want to do any update to local storage or something like that i just want that the user get to display the notification
my index.js file
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import bgMessaging from './bgMessaging';
import messaging from '@react-native-firebase/messaging';
// messaging().setBackgroundMessageHandler(async remoteMessage => {
// console.log('Message handled in the background!', remoteMessage);
// });
AppRegistry.registerComponent(appName, () => App);
// AppRegistry.registerHeadlessTask(
// 'RNFirebaseBackgroundMessage',
// () => bgMessaging,
// );
let me know @Salakar if you need more info, i am willing to provide
Our issue might not be related to @bhaveshdaswani93 , but to provide some additional information for our setup - with the app in the foreground, notifications are received correctly.
With the application in the background, the notification isn't received and we get the following from logcat:
2020-05-15 13:31:08.461 3699-3699/club.sorted.cook E/AndroidRuntime: FATAL EXCEPTION: main
Process: club.sorted.cook, PID: 3699
java.lang.RuntimeException: Unable to start service io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService@7fd7f58 with Intent { cmp=club.sorted.cook/io.invertase.firebase.messaging.ReactNativeFirebaseMessagingHeadlessService (has extras) }: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3724)
at android.app.ActivityThread.access$1600(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.facebook.react.HeadlessJsTaskService.getReactNativeHost(HeadlessJsTaskService.java:166)
at com.facebook.react.HeadlessJsTaskService.startTask(HeadlessJsTaskService.java:97)
at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:48)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3705)
at android.app.ActivityThread.access$1600(ActivityThread.java:200)聽
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)聽
at android.os.Handler.dispatchMessage(Handler.java:106)聽
at android.os.Looper.loop(Looper.java:193)聽
at android.app.ActivityThread.main(ActivityThread.java:6718)聽
at java.lang.reflect.Method.invoke(Native Method)聽
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)聽
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)聽
Our crash doesn't seem to be javascript related - we have no listeners for background notifications or anything like that.
To add to this, not only is the notification not received in the background, but when the app is next opened, it crashes as though the above exception is being processed.
@djw27 that's stack trace shows it's an issue with Expo, you're best reporting it to Expo - can't help you on that one sorry.
Caused by: java.lang.ClassCastException: host.exp.exponent.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.facebook.react.HeadlessJsTaskService.getReactNativeHost(HeadlessJsTaskService.java:166)
at com.facebook.react.HeadlessJsTaskService.startTask(HeadlessJsTaskService.java:97)
at com.facebook.react.HeadlessJsTaskService.onStartCommand(HeadlessJsTaskService.java:48)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3705)
at android.app.ActivityThread.access$1600(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@bhaveshdaswani93 ok thanks - how are you sending the notifications, have you created the channel high-priority that you've referenced as the default channel? Could you show the channel creation code?
I am using firebase cloud messaging console to send the test notification.
and i have not created channel android.
can you show some example of how to create channel in android as i was unaware of that and v5 of this library it provided an option to create channel from js side.
@bhaveshdaswani93 did you listened to the onNotificationOpenedApp & getInitialNotification method?
add this methods to your componentDidMount or useEffect
messaging().onNotificationOpenedApp(remoteMessage => {
console.log( 'Notification caused app to open from background state:', remoteMessage, );
});
// Check whether an initial notification is available
messaging().getInitialNotification().then(remoteMessage => {
console.log( 'Notification caused app to open from quit state:', remoteMessage, );
});
I put your code and it is working.but notification comes in notification tray, the sound of the notification and notification popup does not appear, what is the reason behind that
As far as I can tell, you're receiving background notifications which solves your issue. The sound of the notification and the pop up are, I believe, out of the scope of React Native Firebase API. Therefore, I am closing this issue. Feel free to continue the discussion, and file a bug report if you find any for React Native Firebase modules.
Most helpful comment
I put your code and it is working.but notification comes in notification tray, the sound of the notification and notification popup does not appear, what is the reason behind that