Closed Rishabh02 closed 10 months ago
Thanks for posting the extra detail. This is what I was looking for:
classpath 'com.google.gms:google-services:4.3.8'
https://firebase.google.com/support/release-notes/android indicates they are on version 4.4.0 of the google-services plugin, and that plugin is the component that is responsible for carrying the google-services.json
file from the android
directory of your project into the correct android/app/main/res/......
area where it initializes the [DEFAULT]
app during app startup
Since you are having a [DEFAULT]
initialization area on android, it seems likely that this component may be at fault, and since you indicate you just updated react-native (which normally implies updates to gradle and android-gradle-plugin) it follows that there may be an incompatibility that is resolved if you use the current version of the google-services plugin
Update that thing and give it a try, hopefully it fixes things
Hello,
Thanks for quick response , I tried updating version to 4.4.0 but it still the same issue
classpath 'com.google.gms:google-services:4.4.0'
What should be the alternative ways ? I even tried firebase.initializeApp() with correct messagingSenderId but still it's I am not receiving notifications , getting below error. I am able to generate token from fcm. `broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg=** (has extras) }' Thanks, Rishabh
I do not believe there are alternative ways.
If android firebase startup is not initializing your [DEFAULT]
instance then you'll have to investigate why.
When I have problems like this I usually try to go back to first principles just to prove to myself that it can work.
What does that mean here? do a test/throwaway app as quickly as possible to make sure initialization can work npx react-native init <your project name>
and do an index.js/App.js that is as small as possible to register the messaging listener and prove it can correctly use your google-services.json to initialize the android app and receive the message
That should work, there are no reports that does not work. Now you've proved that it can work, hopefully
Then the task is to figure out where between a stock example app and your project things go wrong... I typically do a binary search in these cases, carrying config / modules from the broken / not initializing project into the example project one chunk at a time, where each chunk is "half of remaining items". At some point it will break, then you back out the chunk you were trying and try just half of it etc. Mathematically, it is improbably that you will need more than 4-5 chunks before you find a specific item and that's it you found your problem. It seems a little daunting but in the end takes 1-2 hours and finds the problem in a pretty deterministic way which is on average more efficient then just trying things and hoping...
I am aslo getting same error I am using "react-native": "0.71.6", and "@react-native-firebase/app": "^18.7.3", "@react-native-firebase/messaging": "^18.7.3",
Just posting the versions is not enough to go on, please do not do that.
Hello, I am getting the same issue and after that i found that in react-native-firebase mentioned that for the react native 0.71 version or below we have to use
classpath 'com.google.gms:google-services:4.3.15'
This fix working for me!!!
Ah, that's very interesting - @hupptechnologies if you could maybe a note on the install docs (just click the edit button at the top right of any page) as a comment on the install snippet where I recommend 4.4.0 that could help people.
In general I test only with up to date versions of everything (to make sure they are compatible...) but that implies that as backwards-compatibility breaks happen I'm not always aware of them. I was not aware of this one
Hello, I am getting the same issue and after that i found that in react-native-firebase mentioned that for the react native 0.71 version or below we have to use
classpath 'com.google.gms:google-services:4.3.15'
This fix working for me!!!
Hi.. Working me when I have reduced it to 4.3.15 version thanks lot bro
Hello @mikehardy
Sorry but i am not getting you exactly that what you want me to do so can you please elaborate in details? Here is already mentioned: https://github.com/invertase/react-native-firebase/blob/main/docs/index.md#configure-firebase-with-android-credentials
Without a reproducible example there will be no progress l, apologies
Sorry - looking more closely, I believe this is a documentation issue but as you point out, it is already handled. I'll update the title of this issue so it perhaps helps future people and close it
[EDIT - SOLUTION] - if you are using react-native 0.71 or below (which brings in an older version of android-gradle-plugin and gradle) then you must not use the google-services gradle plugin 4.4+. You have to stay with 4.3.15 or lower until you upgrade android-gradle-plugin/gradle which usually comes as part of your react-native update process
Issue
I am facing issue Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() after upgrading react native version and firebase dependencies . App was working fine till react native .67 and firebase 16.4.6
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "****", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "android": "react-native run-android", "ios": "react-native run-ios", "postinstall": "patch-package & bash ./postinstall.sh", "pods": "cd ios && rm -rf Pods && pod install && cd ..", "reinstall": "rm -rf node_modules && cd ios && rm -rf Pods && rm Podfile.lock && cd .. && yarn", "android:clean": "cd android && ./gradlew clean && cd ..", "ios:clean": "cd ios && pod upgrade && cd ..", "test": "jest", "test:coverage": "jest --coverage", "test:browse": "open ./coverage/lcov-report/index.html", "apk:debug": "git pull && yarn && mkdir -p android/app/src/main/assets && rm -rf android/app/build && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && cd android && ./gradlew clean && ./gradlew assembleDebug && cd app/build/outputs/apk/debug && open . && cd ../../../../../../ && git clean -df && git checkout .", "apk:release": "git pull && yarn && cd android && ./gradlew clean && ./gradlew assembleRelease && cd app/build/outputs/apk/release && open . && cd ../../../../../../" }, "resolutions": { "react-native-obfuscating-transformer/javascript-obfuscator": "1.0.0" }, "dependencies": { "@openspacelabs/react-native-zoomable-view": "2.1.5", "@react-native-async-storage/async-storage": "1.21.0", "@react-native-camera-roll/camera-roll": "^7.2.0", "@react-native-community/datetimepicker": "7.6.2", "@react-native-community/hooks": "^3.0.0", "@react-native-community/masked-view": "0.1.11", "@react-native-community/netinfo": "9.3.7", "@react-native-community/progress-bar-android": "1.0.5", "@react-native-community/progress-view": "1.4.2", "@react-native-firebase/analytics": "18.7.1", "@react-native-firebase/app": "18.7.1", "@react-native-firebase/crashlytics": "18.7.1", "@react-native-firebase/messaging": "18.7.1", "@react-navigation/bottom-tabs": "6.5.11", "@react-navigation/elements": "^1.3.21", "@react-navigation/native": "6.1.9", "@react-navigation/stack": "6.3.20", "@redux-devtools/extension": "^3.2.6", "axios": "1.3.4", "base64-js": "1.5.1", "date-fns": "2.30.0", "date-fns-timezone": "0.1.4", "fbjs": "^3.0.5", "htmlparser2": "9.0.0", "jetifier": "2.0.0", "lodash": "4.17.21", "opentok-react-native": "2.26.1", "patch-package": "8.0.0", "postinstall-postinstall": "2.1.0", "prop-types": "15.8.1", "punycode": "2.3.1", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.72.7", "react-native-actionsheet": "2.4.2", "react-native-androw": "0.0.34", "react-native-camera": "^4.2.1", "react-native-charts-wrapper": "0.6.0", "react-native-circular-progress": "1.3.9", "react-native-collapsible": "1.6.1", "react-native-config": "1.5.1", "react-native-device-info": "10.12.0", "react-native-device-settings": "1.2.0", "react-native-document-picker": "9.0.1", "react-native-event-listeners": "1.0.7", "react-native-fingerprint-scanner": "6.0.0", "react-native-fs": "2.20.0", "react-native-gesture-handler": "2.14.0", "react-native-hyperlink": "0.0.22", "react-native-image-crop-picker": "0.40.2", "react-native-iphone-x-helper": "1.3.1", "react-native-keep-awake": "4.0.0", "react-native-keyboard-aware-scroll-view": "0.9.5", "react-native-keychain": "8.1.2", "react-native-linear-gradient": "2.8.3", "react-native-localize": "3.0.4", "react-native-parsed-text": "0.0.22", "react-native-pdf": "6.2.2", "react-native-permissions": "3.10.1", "react-native-progress": "5.0.1", "react-native-reanimated": "3.6.0", "react-native-render-html": "4.1.2", "react-native-render-html-table-bridge": "0.5.0", "react-native-restart": "0.0.27", "react-native-safe-area-context": "4.7.4", "react-native-screens": "3.27.0", "react-native-securerandom": "1.0.1", "react-native-status-bar-height": "2.6.0", "react-native-svg": "14.0.0", "react-native-svg-transformer": "1.1.0", "react-native-switch": "^1.5.1", "react-native-text-size": "4.0.0-rc.1", "react-native-webview": "13.6.3", "react-native-wrapped-text": "1.2.2", "react-redux": "8.1.3", "realm": "12.3.1", "redux": "4.2.1", "redux-devtools-extension": "^2.13.9", "redux-logger": "^3.0.6", "redux-mock-store": "^1.5.4", "redux-persist": "^6.0.0", "redux-thunk": "2.4.2", "reselect": "^5.0.1", "rn-fetch-blob": "^0.12.0", "truncate-html": "^1.0.4", "url-parse": "^1.5.10" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/plugin-transform-react-jsx-source": "^7.5.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native-community/eslint-config": "^2.0.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.11", "@tsconfig/react-native": "^3.0.0", "@types/jest": "^26.0.20", "@types/react": "^18.0.24", "@types/react-test-renderer": "^18.0.0", "axios-mock-adapter": "^1.18.1", "babel-eslint": "^10.0.3", "babel-jest": "^29.2.1", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "babel-plugin-transform-remove-console": "^6.9.4", "babel-traverse": "^6.26.0", "babylon": "^6.18.0", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.6", "eslint": "^8.19.0", "eslint-plugin-import": "^2.20.2", "eslint-plugin-jest": "^23.13.2", "eslint-plugin-react": "^7.20.0", "eslint-plugin-react-hooks": "^4.0.4", "eslint-plugin-react-native": "^3.8.1", "husky": "^4.2.5", "jest": "^29.2.1", "jest-date-mock": "^1.0.8", "merge-deep": "^3.0.2", "metro-react-native-babel-preset": "0.76.8", "metro-react-native-babel-transformer": "^0.69.1", "prettier": "^2.4.1", "react-native-obfuscating-transformer": "^1.0.0", "react-test-renderer": "18.2.0", "redux-testkit": "^1.0.6", "typescript": "4.8.4" }, "husky": { "hooks": { "pre-push": "yarn test" } } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```
iOS
Click To Expand
#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```
Android
This issue is occurring on Android only and I am not using any other secondary app. I even tried initialising Firebase app in my App.js class using below code `import firebase from '@react-native-firebase/app'; const options = { appId: "**", projectId: "**-**", apiKey: "**", databaseURL:**", messagingSenderId:"**", storageBucket: "**" } firebase.initializeApp(options);` But Still unable to receive notification on Android and after checking Android native Log , I am getting below exception `broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE pkg= (has extras) }`
#### 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`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { buildToolsVersion = "33.0.2" minSdkVersion = 23 compileSdkVersion = 33 targetSdkVersion = 33 // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP. ndkVersion = "23.1.7779620" } repositories { google() mavenLocal() mavenCentral() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") classpath 'com.google.gms:google-services:4.3.8' classpath 'io.fabric.tools:gradle:1.28.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. content { excludeGroup "com.facebook.react" } } jcenter() 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' } maven { // Android JSC is installed from npm url "$rootDir/../node_modules/jsc-android/dist" } maven { url 'https://www.jitpack.io' } maven { url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' } // maven { // url "http://tokbox.bintray.com/maven" // } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } } } subprojects { afterEvaluate {project -> if (project.hasProperty("android")) { android { compileSdkVersion 33 buildToolsVersion "33.0.2" } } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply plugin: 'io.fabric' apply plugin: "com.facebook.react" 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: true, // we can't enable hermes - realm issue #2455 ] // apply from: "../../node_modules/react-native/react.gradle" // apply from: "../../node_modules/@sentry/react-native/sentry.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", true) /** * Architectures to build native code for in debug. */ def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") android { ndkVersion rootProject.ext.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "*****" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 599 versionName "12.0" multiDexEnabled true // multiDexKeepProguard file('proguard-rules.pro') vectorDrawables.useSupportLibrary = true resValue "string", "build_config_package", "com.*****" missingDimensionStrategy 'react-native-camera', 'general' resConfigs "en" } // for cli building // need to move *.keystore file to/android/app/
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
// splits {
// abi {
// reset()
// enable enableSeparateBuildPerCPUArchitecture
// universalApk false // If true, also generate a universal APK
// include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
// }
// }
// buildTypes {
// if( System.getenv("APPCENTER_BUILD_ID") == null ){
// release {
// debuggable false
// shrinkResources enableProguardInReleaseBuilds
// zipAlignEnabled enableProguardInReleaseBuilds
// minifyEnabled enableProguardInReleaseBuilds
// useProguard enableProguardInReleaseBuilds
// setProguardFiles([getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'])
// // for cli building
// signingConfig signingConfigs.release
// }
// } else {
// release {
// debuggable false
// shrinkResources enableProguardInReleaseBuilds
// zipAlignEnabled enableProguardInReleaseBuilds
// minifyEnabled enableProguardInReleaseBuilds
// useProguard enableProguardInReleaseBuilds
// setProguardFiles([getDefaultProguardFile('proguard-android-optimize.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 =
// defaultConfig.versionCode * 1000 + versionCodes.get(abi)
// }
// }
// }
lintOptions {
abortOnError false
}
// for react-native-pdf
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}
dependencies {
// implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'androidx.appcompat:appcompat:1.2.0'
// implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation "com.google.android.gms:play-services-gcm:17.0.0"
implementation 'com.salesforce.service:chat-ui:4.3.6'
implementation "me.leolin:ShortcutBadger:1.1.22@aar"
implementation "androidx.security:security-crypto:1.1.0-alpha03"
implementation 'commons-io:commons-io:2.4'
implementation("com.facebook.react:react-android")
configurations.all {
resolutionStrategy {
force 'com.opentok.android:opentok-android-sdk:2.21.4'
}
}
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
// 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")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} 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.implementation
// into 'libs'
// }
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
```
#### `android/settings.gradle`:
```groovy
rootProject.name = '****'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
```
#### `MainApplication.java`:
```java
package com.***;
import java.util.List;
import androidx.appcompat.app.AppCompatDelegate;
import android.app.Application;
import android.content.res.Configuration;
import android.text.TextUtils;
import android.view.View;
import com.****.prefrences.MySharedPreference;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.defaults.DefaultReactNativeHost;
import ##com.****.modules.SplashScreen.SplashScreenPackage;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List packages = new PackageList(this).getPackages();
packages.add(new SFChatPackage());
packages.add(new SHUtilitiesPackage());
packages.add(new RNEncryptedStoragePackage());
packages.add(new SplashScreenPackage());
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected boolean isNewArchEnabled() {
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}
@Override
protected Boolean isHermesEnabled() {
return BuildConfig.IS_HERMES_ENABLED;
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
// LTR setting callback
private void lrtSettings(){
String usrRtl=MySharedPreference.getInstance(getApplicationContext()).getUserRTL();
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
if(TextUtils.isEmpty(usrRtl)) {
Configuration config = getResources().getConfiguration();
if(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
sharedI18nUtilInstance.forceRTL(this,true);
sharedI18nUtilInstance.allowRTL(this, true);
}else{
sharedI18nUtilInstance.forceRTL(this,false);
sharedI18nUtilInstance.allowRTL(this, false);
}
}else{
if(usrRtl.equalsIgnoreCase("true")){ //true---> RTL
sharedI18nUtilInstance.forceRTL(this,true);
sharedI18nUtilInstance.allowRTL(this, true);
}else{
sharedI18nUtilInstance.forceRTL(this,false);
sharedI18nUtilInstance.allowRTL(this, false);
}
}
}
@Override
public void onCreate() {
super.onCreate();
lrtSettings();
SoLoader.init(this, /* native exopackage */ false);
// initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
// Fix Xiaomi NightMode
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
}
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
// /**
// * Loads Flipper in React Native templates.
// *
// * @param context
// * @param reactInstanceManager
// */
// private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
// if (BuildConfig.DEBUG) {
// try {
// Class> aClass = Class.forName("com.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
```
Environment
Click To Expand
**`react-native info` output:** ``` OUTPUT GOES HERE ``` - **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:** - `@react-native-firebase/app": "18.7.1` - **`Firebase` module(s) you're using that has the issue:** - `"@react-native-firebase/messaging": "18.7.1", - "@react-native-firebase/crashlytics": "18.7.1" - "@react-native-firebase/analytics": "18.7.1" - ` - **Are you using `TypeScript`?** - `N`
React Native Firebase
andInvertase
on Twitter for updates on the library.