馃敟 Crash - Tried to start task RNFirebaseBackgroundMessage while in foreground, but this is not allowed.
Looks like this issue should be fixed in https://github.com/invertase/react-native-firebase/pull/1491 but we still can reproduce it.
The exception happens in this line of react-native code: https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/jstasks/HeadlessJsTaskContext.java#L98
Looks like that happen because reactContext.getLifecycleState() == LifecycleState.RESUMED condition is true.
Stacktrace:
com.facebook.react.jstasks.HeadlessJsTaskContext.startTask
HeadlessJsTaskContext.java, line 95
java.lang.IllegalStateException: Tried to start task RNFirebaseBackgroundMessage while in foreground, but this is not allowed.
com.facebook.react.jstasks.HeadlessJsTaskContext.startTask HeadlessJsTaskContext.java:95
com.facebook.react.HeadlessJsTaskService$2.run HeadlessJsTaskService.java:127
android.os.Handler.handleCallback Handler.java:739
android.os.Handler.dispatchMessage Handler.java:95
android.os.Looper.loop Looper.java:158
android.app.ActivityThread.main ActivityThread.java:7224
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:1230
com.android.internal.os.ZygoteInit.main ZygoteInit.java:1120
Click To Expand
#### `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? - [ ] 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`:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven { url 'https://dl.bintray.com/android/android-tools' }
}
// https://stackoverflow.com/questions/52113549/app-getting-stuck-with-e-com-facebook-internal-attributionidentifiers/52115743
configurations.all {
resolutionStrategy {
force 'com.facebook.android:facebook-android-sdk:4.34.0'
}
}
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
}
}
}
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 19
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
#### `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",
*
* // 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"
]
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 = true
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
/**
* Read version and versionCode from our build.json file so RE
* can bump the version in one place
*/
import groovy.json.JsonSlurper
def packageSlurper = new JsonSlurper()
def buildJSON= packageSlurper.parse file('../../build.json')
def version = buildJSON.version
def bundleVersion = buildJSON.versionCode
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "our applicationId"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode bundleVersion
versionName version
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "x86-64", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
debuggable false
signingConfig signingConfigs.release
}
}
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "x86-64":3, "arm64-v8a":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
}
}
}
dexOptions {
jumboMode true
}
}
dependencies {
implementation project(':react-native-cookies')
implementation project(':react-native-sensitive-info')
implementation project(':react-native-image-resizer')
implementation project(':react-native-screens')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-sms-retriever')
implementation project(':lottie-react-native')
implementation project(':react-native-fast-image')
implementation project(':react-native-prompt-android')
implementation project(':react-native-gallery-manager')
implementation project(':@huston007_react-native-eventsource')
implementation project(':react-native-firebase')
implementation project(':react-native-appsflyer')
implementation project(':react-native-android-open-settings')
implementation project(':appcenter-crashes')
implementation project(':appcenter-analytics')
implementation project(':appcenter')
implementation project(':react-native-splash-screen')
implementation (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
implementation 'com.android.support:exifinterface:25.+'
implementation ('com.google.android.gms:play-services-vision:12.0.1') {
force = true
}
}
implementation ('com.android.support:exifinterface:26.0.1') {
force = true;
}
implementation project(':react-native-fbsdk')
implementation project(':react-native-restart')
implementation project(':react-native-device-info')
implementation project(':react-native-svg')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-carrier-info')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
implementation "com.google.firebase:firebase-core:16.0.8"
implementation "com.google.firebase:firebase-messaging:17.5.0"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-wallet:16.0.0'
implementation 'me.leolin:ShortcutBadger:1.1.22@aar'
implementation project(':react-native-geolocation-service')
implementation "com.google.android.gms:play-services-location:16.0.0"
}
// 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 plugin: 'com.google.gms.google-services'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
#### `android/settings.gradle`:
rootProject.name = 'ourprojectname'
include ':react-native-cookies'
project(':react-native-cookies').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-cookies/android')
include ':react-native-restart'
project(':react-native-restart').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart/android')
include ':react-native-sensitive-info'
project(':react-native-sensitive-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensitive-info/android')
include ':react-native-image-resizer'
project(':react-native-image-resizer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-resizer/android')
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-sms-retriever'
project(':react-native-sms-retriever').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sms-retriever/android')
include ':lottie-react-native'
project(':lottie-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/lottie-react-native/src/android')
include ':react-native-fast-image'
project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')
include ':react-native-prompt-android'
project(':react-native-prompt-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-prompt-android/android')
include ':react-native-gallery-manager'
project(':react-native-gallery-manager').projectDir = new File(rootProject.projectDir, '../modules/react-native-gallery-manager/android')
include ':@huston007_react-native-eventsource'
project(':@huston007_react-native-eventsource').projectDir = new File(rootProject.projectDir, '../modules/react-native-eventsource/android')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-appsflyer'
project(':react-native-appsflyer').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-appsflyer/android')
include ':react-native-android-open-settings'
project(':react-native-android-open-settings').projectDir = new File(rootProject.projectDir, '../modules/react-native-android-open-settings/android')
include ':appcenter-crashes'
project(':appcenter-crashes').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-crashes/android')
include ':appcenter-analytics'
project(':appcenter-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter-analytics/android')
include ':appcenter'
project(':appcenter').projectDir = new File(rootProject.projectDir, '../node_modules/appcenter/android')
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../modules/react-native-camera/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
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-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-svg/android')
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-carrier-info'
project(':react-native-carrier-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-carrier-info/android')
include ':react-native-geolocation-service'
project(':react-native-geolocation-service').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geolocation-service/android')
include ':app'
#### `MainApplication.java`:
package com.ourappname.app;
import android.support.multidex.MultiDexApplication;
import com.BV.LinearGradient.LinearGradientPackage;
import com.appsflyer.reactnative.RNAppsFlyerPackage;
import com.avishayil.rnrestart.ReactNativeRestartPackage;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
import com.facebook.react.ReactApplication;
import br.com.classapp.RNSensitiveInfo.RNSensitiveInfoPackage;
import fr.bamlab.rnimageresizer.ImageResizerPackage;
import com.ourappname.packages.backdoor.Backdoor;
import com.ourappname.packages.backdoor.BackdoorPackage;
import com.swmansion.rnscreens.RNScreensPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import me.furtado.smsretriever.RNSmsRetrieverPackage;
import com.airbnb.android.react.lottie.LottiePackage;
import com.dylanvann.fastimage.FastImageViewPackage;
import im.shimo.react.prompt.RNPromptPackage;
import org.pentarex.rngallerymanager.RNGalleryManagerPackage;
import com.github.jonnybgod.RNEventSource.RNEventSourcePackage;
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.horcrux.svg.SvgPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.levelasquez.androidopensettings.AndroidOpenSettingsPackage;
import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage;
import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
import com.psykar.cookiemanager.CookieManagerPackage;
import com.ianlin.RNCarrierInfo.RNCarrierInfoPackage;
import com.dooboolab.RNIap.RNIapPackage;
import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import org.reactnative.camera.RNCameraPackage;
import java.util.Arrays;
import java.util.List;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.notifications.RNFirebaseNotificationsPackage;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private Backdoor mBackdoor = null;
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNSensitiveInfoPackage(),
new ImageResizerPackage(),
new RNScreensPackage(),
new RNGestureHandlerPackage(),
new RNSmsRetrieverPackage(),
new LottiePackage(),
new FastImageViewPackage(),
new RNIapPackage(),
new RNPromptPackage(),
new RNGalleryManagerPackage(),
new RNEventSourcePackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseNotificationsPackage(),
new RNAppsFlyerPackage(),
new AndroidOpenSettingsPackage(),
new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
new AppCenterReactNativePackage(MainApplication.this),
new SplashScreenReactPackage(),
new RNCameraPackage(),
new FBSDKPackage(mCallbackManager),
new CookieManagerPackage(),
new ReactNativeRestartPackage(),
new RNDeviceInfo(),
new SvgPackage(),
new LinearGradientPackage(),
new RNCarrierInfoPackage(),
new RNFusedLocationPackage(),
new BackdoorPackage(mBackdoor)
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
mBackdoor = new Backdoor();
SoLoader.init(this, /* native exopackage */ false);
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
public Object getBackdoor() {
return mBackdoor;
}
}
#### `AndroidManifest.xml`:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.our.app">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:largeHeap="true"
tools:replace="android:allowBackup">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:autoVerify="true">
<!-- This is just configuration -->
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="ourappname.com" />
<data android:scheme="https"
android:host="*.ourappname.com" />
<data android:scheme="ourappname"
android:host="ourappname" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:launchMode="singleTop" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="@string/default_notification_channel_id"/>
<activity
android:name="com.facebook.FacebookActivity"
android:launchMode="singleTop"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:launchMode="singleTop"
android:exported="true"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider206111500078496"
android:exported="true"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</provider>
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
</manifest>
Click To Expand
**`react-native info` output:**
React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
Memory: 261.26 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.15.2 - ~/.nvm/versions/node/v8.12.0/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
@types/react: ^16.8.4 => 16.8.4
@types/react-native: ^0.57.38 => 0.57.38
react: 16.8.3 => 16.8.3
react-native: 0.59.10 => 0.59.10
- **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:**
- `e.g. 5.3.1`
- **`Firebase` module(s) you're using that has the issue:**
- `react-native-firebase`
- **Are you using `TypeScript`?**
- `Y`
@Salakar can you take a look please?
@Ehesp can you take a look please?
I think you might want to paste in the full code you use to define and register the headless task. And is there some pattern to when the error occurs? How frequent, maybe on some devices not others? I'm not sure where you'd get control in the stack you presented as I read the relevant react-native code and it doesn't look to me like react-native-firebase even has control there?
@mikehardy
I think you might want to paste in the full code you use to define and register the headless task. And is there some pattern to when the error occurs?
react-native-firebase has no control there, but it's not about control. It's about when RNFirebaseBackgroundMessage was triggered. If it triggered in foreground it's lead us to exception, as I said before I find similar issue in react-native-firebase: https://github.com/invertase/react-native-firebase/pull/1491. Can you check this? Maybe it wasn't fixed properly?
Code on my side looks like this: AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => backgroundMessagingAndroid);
聽
If I understand correctly - I just add function which should be called on RNFirebaseBackgroundMessage. But I receive exception before backgroundMessagingAndroid was called. So probably it's not my fault.
And is there some pattern to when the error occurs?
Looks like error occurs when we receive some push notification.
How frequent, maybe on some devices not others?
5-30 events per day (it's depends), different devices, different android versions:
ZTE BLade Zmax Android 7.1.1 Sep 25, 1:57 PM
Galaxy J3(2017) Android 7.0 Sep 25, 7:36 AM
Galaxy J3(2017) Android 7.0 Sep 25, 7:36 AM
Galaxy J7 Android 8.1.0 Sep 25, 4:45 AM
LG Stylo 4 Android 8.1.0 Sep 25, 1:27 AM
Galaxy Core Prime Android 5.0.2 Sep 24, 11:16 PM
Galaxy Core Prime Android 5.0.2 Sep 24, 11:16 PM
LG K30 Android 8.1.0 Sep 24, 3:04 AM
U683CL Android 8.1.0 Sep 24, 1:40 AM
Galaxy J5 Android 6.0.1 Sep 23, 6:40 PM
Galaxy J5 Android 6.0.1 Sep 23, 6:39 PM
ALCATEL ONETOUCH PIXI 4 (4) Android 6.0 Sep 22, 10:19 PM
Moto TAB Android 7.1.1 Sep 22, 9:14 PM
I got the same crash reports on crashlytics
I got the same crash today when the app is in the background and I received a notification.
Seeing same crash in Sentry right now.
I got it too.
@Salakar @Ehesp @mikehardy any attention to this issue? Please?
Sorry I'm not sure what to do about this one. Perhaps it's possible to do something in this project to make taskConfig.isAllowedInForeground() true? But I haven't looked into it deeply and don't have a lot of experience with the headless tasks and messaging myself
Also, this may not be popular, but I see from the original entry at least that you are on RNFB v5.3, can you still reproduce this on v5.5.6 + most current android firebase sdks (that's BoM 24.1.0 I think)
This happens to me on 5.5.6 as well
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.
Still an issue. I could reproduce this by closing the app, sending a push to it, and at the same time opening the app in the foreground.
Then a race condition occurs, if the react-native-fabric module gets the push while in the background, and then tries to start the background service, but then the app enters foreground... then it will crash.
A possible fix would be to pass in 'allowedInForeground: true' in HeadlessJsTaskConfig inside
RNFirebaseBackgroundMessagingService.
However I'm not sure this would be the best solution? App would go into the foreground, and then a call would come in on the headless task entry point...
I am also facing the same issue. I am in react-native-firebase v5.6.0
any updates ?
I have same issue on version ~5.6.4~ 5.5.6 (updated)
This version seems to be fixed but it's not!
https://rnfirebase.io/docs/v5.x.x/releases/v5.0.0
@luatnd there is no version 5.6.4
@mikehardy can you reopen this issue as it seems this is still ongoing? It's #1 crash for our app per crashlytics so it would be great if this is fixed
Sure - the community will have to come up with something though, the v5.x.x series is on life support only and as a maintainer I have 2 fixes queued for release - I'm willing to do a release - but they are community driven. I'll take solid PRs and get them out there but I don't have time to investigate unfortunately
@mikehardy thanks Mike - just sent out PR - #3311
Most helpful comment
I got the same crash reports on crashlytics