<!---
**Note <= v5 is deprecated, v5 issues are unlikely to get attention. Feel… free to ask in discussions instead.**
Hello there you awesome person;
Please note that the issue list of this repo is exclusively for bug reports;
1) For feature requests, questions and general support please use [GitHub Discussions](https://github.com/invertase/react-native-firebase/discussions).
2) If this is a setup issue then please make sure you've correctly followed the setup guides, most setup issues such as 'duplicate dex files', 'default app has not been initialized' etc are all down to an incorrect setup as the guides haven't been correctly followed.
-->
## Issue
When I run `yarn upgrade-interactive --latest` it shows me that the following packages that I am using are now at 12.4
- @react-native-firebase/analytics
- @react-native-firebase/app
- @react-native-firebase/crashlytics
- @react-native-firebase/messaging
But `@react-native-firebase/iid` is still on `11.5`, if I try to upgrade, then do `pod install --repo-update` I will get the following warnings:
```
[!] NPM package '@react-native-firebase/iid' depends on '@react-native-firebase/app' v11.5.0 but found v12.4.0, this might cause build issues or runtime crashes.
[!] NPM package '@react-native-firebase/iid' depends on '@react-native-firebase/app' v11.5.0 but found v12.4.0, this might cause build issues or runtime crashes.
```
then if I try to run on my ios device, I will get lots of errors about `using undefined identifier`, here are some:
`@react-native-firebase/iid/ios/RNFBIid/RNFBIidModule.m:43:7: Use of undeclared identifier 'FIRInstanceID'`
`@react-native-firebase/iid/ios/RNFBIid/RNFBIidModule.m:68:7: Use of undeclared identifier 'FIRInstanceID'`
`@react-native-firebase/iid/ios/RNFBIid/RNFBIidModule.m:136:12: Use of undeclared identifier 'FIRInstanceIDErrorInvalidRequest'; did you mean 'FIRMessagingErrorInvalidRequest'?`
All of which are in firebase iid.
---
## Project Files
### Javascript
<details><summary>Click To Expand</summary>
<p>
#### `package.json`:
```json
{
"name": "myapp",
"version": "1.3.5",
"private": true,
"scripts": {
"android-dev": "cd android && ./gradlew clean && cd .. && react-native run-android --variant=devDebug",
"android-production": "react-native run-android --variant=productionRelease",
"start": "react-native start",
"test": "jest",
"eslint": "eslint \"**/*.js\" --fix",
"prettier": "prettier \"**/*.js\" --write",
"lint": "npm run prettier && npm run eslint",
"postinstall": "husky install && patch-package",
"bootsplash": "react-native generate-bootsplash assets/bootsplash_logo_original.png --background-color=28003A --logo-width=150 --flavor=main",
"patch-packages": "patch-package react-native-paper react-native-push-notification-popup rn-placeholder",
"bundle-js": "react-native bundle --entry-file index.js --bundle-output ios/main.jsbundle",
"postversion": "react-native-version",
"keystore-password": "node scripts/keystorePassword.js"
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "^6.0.0",
"@react-native-firebase/analytics": "^12.4.0",
"@react-native-firebase/app": "^12.4.0",
"@react-native-firebase/crashlytics": "^12.4.0",
"@react-native-firebase/iid": "^11.5.0",
"@react-native-firebase/messaging": "^12.4.0",
"@react-navigation/bottom-tabs": "^5.11.11",
"@react-navigation/drawer": "^5.12.5",
"@react-navigation/native": "^5.9.4",
"@react-navigation/stack": "^5.14.5",
"color": "^4.0.0",
"date-fns": "^2.23.0",
"expo-image-picker": "^10.2.2",
"fluxible-js": "^5.0.11",
"hermes-engine": "0.7.2",
"husky": "7.0.1",
"jsc-android": "^250230.2.1",
"patch-package": "^6.4.7",
"postinstall-postinstall": "^2.1.0",
"react": "17.0.2",
"react-fluxible": "^5.0.4",
"react-native": "0.64.2",
"react-native-add-calendar-event": "^4.0.0",
"react-native-animatable": "^1.3.3",
"react-native-background-timer": "^2.4.1",
"react-native-bootsplash": "^3.2.4",
"react-native-bouncy-checkbox": "^2.1.3",
"react-native-camera-kit": "^11.2.1",
"react-native-config": "^1.4.3",
"react-native-device-info": "^8.1.5",
"react-native-fs": "^2.18.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-google-places": "^3.1.2",
"react-native-maps": "^0.28.0",
"react-native-mime-types": "^2.3.0",
"react-native-modalize": "^2.0.8",
"react-native-paper": "^4.9.2",
"react-native-permissions": "^3.0.5",
"react-native-portalize": "^1.0.7",
"react-native-push-notification-popup": "^1.6.0",
"react-native-qrcode-svg": "^6.1.1",
"react-native-reanimated": "^2.2.0",
"react-native-responsive-image-view": "^2.1.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.4.0",
"react-native-sensitive-info": "^6.0.0-alpha.8",
"react-native-svg": "^12.1.1",
"react-native-unimodules": "^0.14.6",
"react-native-vector-icons": "^8.1.0",
"react-native-walkthrough-tooltip": "^1.2.0",
"rn-placeholder": "^3.0.3",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@babel/eslint-parser": "^7.14.7",
"@babel/runtime": "^7.14.8",
"@react-native-community/eslint-config": "^3.0.0",
"babel-jest": "^27.0.6",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-optional-require": "^0.3.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"command-line-args": "^5.2.0",
"eslint": "^7.32.0",
"eslint-import-resolver-babel-module": "^5.3.1",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-module-resolver": "^1.4.0",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^27.0.6",
"lint-staged": "^11.1.1",
"metro-react-native-babel-preset": "^0.66.2",
"prettier": "^2.3.2",
"react-native-version": "^4.0.0",
"react-test-renderer": "17.0.2",
"source-map": "^0.7.3"
},
"jest": {
"preset": "react-native"
},
"lint-staged": {
"*.js": [
"prettier --write",
"eslint --fix"
]
}
}
```
#### `firebase.json` for react-native-firebase v6:
I don't know what this is...
```json
# N/A
```
</details>
### iOS
<details><summary>Click To Expand</summary>
<p>
#### `ios/Podfile`:
- [ ] I'm not using Pods
- [x] I'm using Pods and my Podfile looks like:
```ruby
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
platform :ios, '12.0'
project 'myapp',
'DevDebug' => :debug,
'DevRelease' => :release
target 'myapp' do
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Calendars', :path => "#{permissions_path}/Calendars"
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
use_unimodules!(exclude: ['expo-permissions'])
# React Native Maps dependencies
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
target 'myappTests' do
inherit! :complete
# Pods for testing
end
if ENV['NODE_ENV'] != 'production'
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!({
'Flipper' => '0.93.0',
'Flipper-Folly' => '~> 2.6'
})
post_install do |installer|
flipper_post_install(installer)
end
end
end
target 'myapp-tvOS' do
# Pods for myapp-tvOS
target 'myapp-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
```
#### `AppDelegate.m`:
```objc
#import "AppDelegate.h"
@import GooglePlaces;
@import GoogleMaps;
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <GoogleMaps/GoogleMaps.h>
#import "RNBootSplash.h"
#import <Firebase.h>
#import "RNFBMessagingModule.h"
#import <UMCore/UMModuleRegistry.h>
#import <UMReactNativeAdapter/UMNativeModulesProxy.h>
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
#ifdef FB_SONARKIT_ENABLED
#import <FlipperKit/FlipperClient.h>
#import <FlipperKitLayoutPlugin/FlipperKitLayoutPlugin.h>
#import <FlipperKitUserDefaultsPlugin/FKUserDefaultsPlugin.h>
#import <FlipperKitNetworkPlugin/FlipperKitNetworkPlugin.h>
#import <SKIOSNetworkPlugin/SKIOSNetworkAdapter.h>
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h>
static void InitializeFlipper(UIApplication *application) {
FlipperClient *client = [FlipperClient sharedClient];
SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
[client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
[client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
[client addPlugin:[FlipperKitReactPlugin new]];
[client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
[client start];
}
#endif
@interface AppDelegate () <RCTBridgeDelegate>
@property (nonatomic, strong) UMModuleRegistryAdapter *moduleRegistryAdapter;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[GMSPlacesClient provideAPIKey:@"AIzaSyAuHLfStH7B6MEdPu0jOsxnwxlPDFp4a_A"];
[GMSServices provideAPIKey:@"AIzaSyAuHLfStH7B6MEdPu0jOsxnwxlPDFp4a_A"];
[FIRApp configure];
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
self.moduleRegistryAdapter = [[UMModuleRegistryAdapter alloc] initWithModuleRegistryProvider:[[UMModuleRegistryProvider alloc] init]];
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
NSDictionary *appProperties = [RNFBMessagingModule addCustomPropsToUserProps:nil withLaunchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:@"myapp"
initialProperties:appProperties];
if (@available(iOS 13.0, *)) {
rootView.backgroundColor = [UIColor systemBackgroundColor];
} else {
rootView.backgroundColor = [UIColor whiteColor];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[super application:application didFinishLaunchingWithOptions:launchOptions];
[RNBootSplash initWithStoryboard:@"BootSplash" rootView:rootView];
return YES;
}
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge
{
NSArray<id<RCTBridgeModule>> *extraModules = [_moduleRegistryAdapter extraModulesForBridge:bridge];
// If you'd like to export some custom RCTBridgeModules that are not Expo modules, add them here!
return extraModules;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
@end
```
</p>
</details>
---
### Android
<details><summary>Click To Expand</summary>
<p>
#### Have you converted to AndroidX?
- [x] 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`:
```groovy
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 23
compileSdkVersion = 30
targetSdkVersion = 30
kotlin_version = '1.4.10'
ndkVersion = "20.1.5948944"
supportLibVersion = "28.0.0"
playServicesVersion = "17.0.0"
androidMapsUtilsVersion = "2.2.4"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
// 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://www.jitpack.io' }
maven { url "https://maven.google.com" }
}
}
```
#### `android/app/build.gradle`:
```groovy
apply plugin: "com.android.application"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
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. If none specified and
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
* // default. Can be overridden with ENTRY_FILE environment variable.
* entryFile: "index.android.js",
*
* // https://reactnative.dev/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 = [
enableHermes: true, // 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 {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
multiDexEnabled true
applicationId "com.aprmp.myapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 41
versionName "1.3.5"
resValue "string", "build_config_package", "com.aprmp.myapp"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
}
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
}
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 {
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
flavorDimensions "version"
productFlavors {
dev {
applicationIdSuffix ".dev"
}
production {}
}
// 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
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
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 =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation project(':react-native-fs')
addUnimodulesDependencies([exclude: ['expo-permissions']])
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
compile project(':react-native-google-places')
}
// 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)
project.ext.vectoricons = [
iconFontNames: [
'Ionicons.ttf',
'AntDesign.ttf',
'MaterialCommunityIcons.ttf',
'Feather.ttf'
]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
```
#### `android/settings.gradle`:
```groovy
rootProject.name = 'myapp'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
apply from: '../node_modules/react-native-unimodules/gradle.groovy'; includeUnimodulesProjects()
include ':app'
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
include ':react-native-google-places'
project(':react-native-google-places').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-places/android')
```
#### `MainApplication.java`:
```java
package com.aprmp.myapp;
import com.aprmp.myapp.generated.BasePackageList;
import androidx.multidex.MultiDexApplication;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Arrays;
import org.unimodules.adapters.react.ModuleRegistryAdapter;
import org.unimodules.adapters.react.ReactModuleRegistryProvider;
import org.unimodules.core.interfaces.SingletonModule;
import com.facebook.react.bridge.JSIModulePackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;
public class MainApplication extends MultiDexApplication implements ReactApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null);
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();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
List<ReactPackage> unimodules = Arrays.<ReactPackage>asList(
new ModuleRegistryAdapter(mModuleRegistryProvider)
);
packages.addAll(unimodules);
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage();
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* @param context
* @param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
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.aprmp.myapp.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
```
#### `AndroidManifest.xml`:
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aprmp.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<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">
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat"
/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize"
android:exported="true"
/>
<activity
android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
android:theme="@style/BootTheme"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyDUU3We_6S9zOz4t1NsilFw45eOVjtudVg"/>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
</manifest>
```
</p>
</details>
---
## Environment
<details><summary>Click To Expand</summary>
<p>
**`react-native info` output:**
```
System:
OS: macOS 11.3
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 27.07 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.10.0 - ~/.nvm/versions/node/v15.10.0/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.20.0 - ~/.nvm/versions/node/v15.10.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /Users/aprilmintacpineda/.rvm/gems/ruby-3.0.2/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
Android SDK:
API Levels: 24, 26, 28, 29, 30
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2
System Images: android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.1 AI-201.8743.12.41.6953283
Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_292 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
```
- **Platform that you're experiencing the issue on**:
- [ ] iOS
- [ ] Android
- [x] **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.4.3`
- **`Firebase` module(s) you're using that has the issue:**
- `e.g. Instance ID`
- **Are you using `TypeScript`?**
- `Y/N` & `VERSION`
</p>
</details>
---
- 👉 Check out [`React Native Firebase`](https://twitter.com/rnfirebase) and [`Invertase`](https://twitter.com/invertaseio) on Twitter for updates on the library.