-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Issue
I have a firebase messaging app that used to work fine, then I was forced to migrate by apple store.
I have migrated my RN app from 0.71 to 0.78.2
I kept my firebase version to the one that used to work there and as per the documentation this should not be an issue. So I am using these:
"@react-native-firebase/app": "10.5.0",
"@react-native-firebase/messaging": "10.5.1",
Both iOS and Android firebase functions stopped working.
It seems an issue in firebase app initialize
As per the documentation, I do not need to call the firebase.initializeApp() explicitly.
So what went wrong
// Init code
import firebase from '@react-native-firebase/app';
var platform = Platform.OS;
let appCount = firebase.apps.length;
console.log(mod + 'initialize, platform=' + platform, ' count=' + appCount, firebase);
if (appCount == 0) {
firebase_App = firebase.initializeApp();
console.log(mod + 'app=', firebase_App);
}
Output:
firebase_config:initialize, platform=android count=0
// Messaging code
import messaging from '@react-native-firebase/messaging';
try {
firebaseFCM = FirebaseTools.firebase.messaging();
} catch (err) {
FCM_Failed = true;
console.warn(mod+'Failed to initialize Firebase Messaging', err);
}
Output:
messaging.js:59 FCM: Failed to initialize Firebase Messaging Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
at getApp (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:150702:22)
at firebaseModuleWithApp (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:150926:76)
at ?anon_0_ (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:151086:109)
at next (native)
at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15728:19)
at next (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15742:29)
at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15747:14)
at tryCallTwo (address at InternalBytecode.js:1:1222)
at doResolve (address at InternalBytecode.js:1:2541)
at Promise (address at InternalBytecode.js:1:1318)
at anonymous (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15739:25)
at apply (native)
at startMessaging (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:151109:37)
at fireInitialize (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:148804:87)
at readyFn (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:97128:77)
at ?anon_0 (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:100555:16)
at next (native)
at asyncGeneratorStep (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15728:19)
at _next (http://localhost:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.egerp.bellagio&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server:15742:29)
at tryCallOne (address at InternalBytecode.js:1:1180)
at anonymous (address at InternalBytecode.js:1:1874)
Describe your issue here
As you can see the messaging api is asking me to do firebase.initializeApp, when It shouldn't.
No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp()
Project Files
Javascript
Click To Expand
package.json:
{
"name": "Bellagio",
"version": "1.0.0",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^2.1.2",
"@react-native-clipboard/clipboard": "^1.16.2",
"@react-native-firebase/app": "10.5.0",
"@react-native-firebase/messaging": "10.5.1",
"@react-navigation/bottom-tabs": "^7.3.10",
"@react-navigation/native": "6.0.8",
"@react-navigation/native-stack": "6.9.7",
"axios": "^1.9.0",
"date-fns": "^4.1.0",
"eslint-plugin-react-hooks": "^4.3.0",
"expo-checkbox": "^4.0.1",
"react": "19.0.0",
"react-native": "0.78.2",
"react-native-calendar-picker": "^8.0.5",
"react-native-device-info": "^14.0.4",
"react-native-dropdown-select-list": "^2.0.5",
"react-native-image-crop-picker": "^0.42.0",
"react-native-popup-menu": "0.16.1",
"react-native-qrcode-svg": "^6.3.15",
"react-native-restart": "^0.0.27",
"react-native-safe-area-context": "^5.4.0",
"react-native-screens": "^4.10.0",
"react-native-super-grid": "^6.0.1",
"react-native-svg": "^15.11.2",
"react-native-vector-icons": "^10.2.0",
"react-native-vision-camera": "^4.6.4"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
"@react-native/babel-preset": "0.78.2",
"@react-native/eslint-config": "0.78.2",
"@react-native/metro-config": "0.78.2",
"@react-native/typescript-config": "0.78.2",
"@types/jest": "^29.5.13",
"@types/react": "^19.0.0",
"@types/react-test-renderer": "^19.0.0",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "19.0.0",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
}
}
firebase.json for react-native-firebase v6:
# N/AiOS
Click To Expand
ios/Podfile:
- I'm not using Pods
- I'm using Pods and my Podfile looks like:
# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
"react-native/scripts/react_native_pods.rb",
{paths: [process.argv[1]]},
)', __dir__]).strip
platform :ios, min_ios_version_supported
prepare_react_native_project!
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! :linkage => linkage.to_sym
end
target 'Bellagio' do
# Firebase
use_frameworks! :linkage => :static
$RNFirebaseAsStaticFramework = true
config = use_native_modules!
# Firebase
pod 'FirebaseCore'
pod 'FirebaseMessaging'
use_react_native!(
:path => config[:reactNativePath],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
config[:reactNativePath],
:mac_catalyst_enabled => false,
# :ccache_enabled => true
)
end
endAppDelegate.swift:
import UIKit
import React
import React_RCTAppDelegate
import ReactAppDependencyProvider
import FirebaseCore
@main
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
self.moduleName = "Bellagio"
self.dependencyProvider = RCTAppDependencyProvider()
// Firebase initialization
FirebaseApp.configure()
if let app = FirebaseApp.app() {
print("Firebase initialized successfully with app name: \(app.name)")
} else {
print("FirebaseApp configuration failed!")
}
// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = [:]
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}
override func bundleURL() -> URL? {
#if DEBUG
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
}
}
Android
Click To Expand
Have you converted to AndroidX?
- my application is an AndroidX application?
- I am using
android/gradle.settingsjetifier=truefor Android compatibility? - I am using the NPM package
jetifierfor react-native compatibility?
android/build.gradle:
buildscript {
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 35
ndkVersion = "27.1.12297006"
kotlinVersion = "2.0.21"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
classpath("com.google.gms:google-services:4.3.15")
}
}
apply plugin: "com.facebook.react.rootproject"
android/app/build.gradle:
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services' // Firebase
// ionIcons
// To customize the fonts being copied, use:
// project.ext.vectoricons = [
// iconFontNames: [ 'MaterialIcons.ttf', 'EvilIcons.ttf' ] // Specify font files
// ]
apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
/* Autolinking */
autolinkLibrariesWithApp()
}
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+`
*
* 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 = 'io.github.react-native-community:jsc-android:2026004.+'
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace "com.bellagio"
defaultConfig {
applicationId "com.egerp.bellagio"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
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("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
}
android/settings.gradle:
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'Bellagio'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
MainApplication.kt:
package com.bellagio
import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
}
}
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- Include this only if you are planning to use the camera roll >
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /-->
<queries>
<package android:name="com.whatsapp.w4b" />
<package android:name="com.whatsapp" />
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https"/>
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="geo" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="mailto" />
</intent>
</queries>
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Environment
Click To Expand
react-native info output:
info Fetching system and libraries information...
System:
OS: macOS 15.4.1
CPU: (10) arm64 Apple M2 Pro
Memory: 108.52 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.15.0
path: ~/.nvm/versions/node/v22.15.0/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v22.15.0/bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v22.15.0/bin/npm
Watchman:
version: 2025.04.14.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/saadalla/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.4
- iOS 18.4
- macOS 15.4
- tvOS 18.4
- visionOS 2.4
- watchOS 11.4
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 16.3/16E140
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.15
path: /usr/bin/javac
Ruby:
version: 2.7.5
path: /Users/saadalla/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 19.0.0
wanted: 19.0.0
react-native:
installed: 0.78.2
wanted: 0.78.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
- Platform that you're experiencing the issue on:
- iOS
- Android
- iOS but have not tested behavior on Android
- Android but have not tested behavior on iOS
- Both
react-native-firebaseversion you're using that has this issue:- 10.5.0
Firebasemodule(s) you're using that has the issue:- "@react-native-firebase/app": "10.5.0",
- "@react-native-firebase/messaging": "10.5.1",
- Are you using
TypeScript?- Not really
- 👉 Check out
React Native FirebaseandInvertaseon Twitter for updates on the library.