Closed YoushaExT closed 11 months ago
Hi there! Some of the integration steps performed (specifically: the build.gradle
change where you added the google-services dependency) are not necessary with react-native-firebase
as we handle this (for that one specifically, it is added for you in the @react-native-firebase/app
module's build.gradle
file)
For the rest - I'm not sure, but I can say the versions in use of react-native-firebase are quite old, and I'd suggest only logging issues after ensuring you can reproduce on current versions
If you can reproduce on 18.5.0+ of react-native-firebase we can reopen
Issue
Subscription conversion events are not being fired on Android
Describe your issue here
These events should be automatically collected on library integration:
I have followed the instructions for Android integration from https://rnfirebase.io/
Instruction:
Implementation:
Instruction:
Implementation:
Instruction:
Implementation:
Project Files
Javascript
Click To Expand
#### `package.json`: ```json { "name": "myapp", "version": "0.0.7", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest --forceExit", "lint": "eslint . --ext .js,.jsx,.ts,.tsx", "commit": "git-cz", "pretty": "prettier --write \"./**/*.{ts,tsx,json,js}\"", "prepare": "husky install", "precommit": "lint-staged", "snapshot": "jest --updateSnapshot", "postinstall": "patch-package" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog-for-jira-smart-commits" } }, "lint-staged": { "*.{js,ts,tsx}": [ "jest --bail --findRelatedTests" ] }, "dependencies": { "@gorhom/bottom-sheet": "^4", "@hookform/resolvers": "^2.9.10", "@react-native-async-storage/async-storage": "^1.17.0", "@react-native-community/cookies": "^5.0.1", "@react-native-community/netinfo": "^8.3.0", "@react-native-community/push-notification-ios": "^1.10.1", "@react-native-firebase/analytics": "^16.4.1", "@react-native-firebase/app": "^16.4.1", "@react-native-firebase/crashlytics": "^16.4.1", "@react-native-firebase/in-app-messaging": "^16.4.1", "@react-native-firebase/messaging": "^16.4.1", "@react-native-firebase/perf": "^16.4.1", "@react-native-firebase/remote-config": "^16.4.1", "@react-navigation/bottom-tabs": "^6.3.1", "@react-navigation/drawer": "^6.3.1", "@react-navigation/material-top-tabs": "^6.1.1", "@react-navigation/native": "^6.0.8", "@react-navigation/native-stack": "^6.5.0", "@reduxjs/toolkit": "^1.8.0", "@types/react-native-push-notification": "^8.1.1", "axios": "^0.26.1", "buffer": "^6.0.3", "i18next": "21.6.13", "inversify": "^6.0.1", "jest-fetch-mock": "^3.0.3", "jsdom-jscore-rn": "^0.1.8", "jwt-decode": "^3.1.2", "lottie-react-native": "^6.3.1", "mixpanel-react-native": "^1.3.10", "moment": "^2.29.3", "object-hash": "^3.0.0", "patch-package": "^8.0.0", "postinstall-postinstall": "^2.1.0", "qs": "^6.10.3", "react": "17.0.2", "react-hook-form": "^7.42.1", "react-i18next": "11.15.5", "react-native": "0.67.3", "react-native-adjust": "^4.29.6", "react-native-app-auth": "^6.4.3", "react-native-appearance": "^0.3.4", "react-native-base64": "^0.2.1", "react-native-big-list": "^1.6.0", "react-native-bouncy-checkbox": "^3.0.6", "react-native-circular-progress": "hamza5746/react-native-circular-progress", "react-native-config": "1.4.5", "react-native-device-info": "^8.7.1", "react-native-devsettings": "^1.0.5", "react-native-encrypted-storage": "^4.0.2", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "^2.13.1", "react-native-html-parser": "^0.1.0", "react-native-in-app-review": "^4.3.3", "react-native-inappbrowser-reborn": "3.7.0", "react-native-insider": "^5.5.2-nh", "react-native-linear-gradient": "^2.5.6", "react-native-logs": "^5.0.1", "react-native-markdown-display": "jonasmerlin/react-native-markdown-display", "react-native-material-ripple": "^0.9.1", "react-native-pager-view": "^5.4.11", "react-native-paper": "^4.12.1", "react-native-permissions": "^3.9.0", "react-native-popup-menu": "^0.15.13", "react-native-purchases": "4.5.3", "react-native-push-notification": "^8.1.1", "react-native-radio-buttons-group": "^2.2.11", "react-native-raw-bottom-sheet": "^2.2.0", "react-native-reanimated": "^2.4.1", "react-native-safe-area-context": "4.1.2", "react-native-screens": "^3.13.1", "react-native-shimmer-placeholder": "^2.0.8", "react-native-simple-toast": "^1.1.3", "react-native-snap-carousel": "^3.9.1", "react-native-sqlcipher": "^0.0.6", "react-native-svg": "^12.3.0", "react-native-tab-view": "^3.1.1", "react-native-toggle-element": "^2.0.1", "react-native-walkthrough-tooltip": "hamza5746/react-native-walkthrough-tooltip", "react-native-webview": "^11.17.2", "react-redux": "^7.2.6", "reactotron-react-native": "^5.0.1", "reflect-metadata": "^0.1.13", "ts-md5": "^1.3.1", "typeorm": "0.3.5", "yup": "^0.32.11" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/plugin-proposal-decorators": "^7.17.9", "@babel/runtime": "^7.19.4", "@react-native-community/eslint-config": "^2.0.0", "@types/jest": "^28.1.3", "@types/node": "^17.0.23", "@types/react": "^18.0.14", "@types/react-native": "^0.69.1", "@types/react-native-i18n": "^2.0.0", "@types/react-native-snap-carousel": "^3.8.5", "@types/react-test-renderer": "^18.0.0", "@typescript-eslint/eslint-plugin": "^5.7.0", "@typescript-eslint/parser": "^5.7.0", "axios-curlirize": "^2.0.0", "babel-jest": "^28.1.2", "babel-plugin-transform-typescript-metadata": "^0.3.2", "commitizen": "^4.2.4", "cz-conventional-changelog-for-jira-smart-commits": "^1.0.5", "eslint": "^7.14.0", "husky": "^8.0.1", "jest": "^28.1.2", "jest-sonar-reporter": "^2.0.0", "lint-staged": "^13.0.3", "metro-react-native-babel-preset": "0.66.2", "msw": "^0.43.0", "react-devtools-core": "4.25.0", "react-native-clean-project": "^4.0.1", "react-native-obfuscating-transformer": "^1.0.0", "react-native-svg-transformer": "^1.0.0", "react-test-renderer": "17.0.2", "sonarqube-scanner": "^2.8.1", "sqlite3": "^5.0.8", "ts-jest": "^28.0.0-next.3", "typescript": "^4.7.4" }, "resolutions": { "react-devtools-core": "~4.25.0" } } ``` #### `firebase.json` for react-native-firebase v6: ```json { "react-native": { "crashlytics_debug_enabled": true } } ```
iOS
Click To Expand
#### `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-permissions/scripts/setup' platform :ios, '16.1' use_frameworks! dynamic_frameworks = ['InsiderMobile', 'InsiderMobileAdvancedNotification'] pre_install do |installer | installer.pod_targets.each do |pod | if !dynamic_frameworks.include? (pod.name) puts "Overriding the static_framework? mothod for " + (pod.name) def pod.static_framework? true end def pod.build_type; Pod::BuildType.static_library end end end end project 'myapp', { 'Debug' => :debug, 'DebugQa' => :debug, 'DebugDev' => :debug, 'Release' => :release, 'ReleaseQa' => :release, 'ReleaseDev' => :release, } target 'myapp' do 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 ) pod 'TrustKit', '1.6.5' target 'myappTests' do inherit! :complete # Pods for testing end pod 'FirebaseCore', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true pod 'InsiderMobile' target 'InsiderNotificationContent' do inherit! :search_paths # Pods for InsiderNotificationContent pod "InsiderMobileAdvancedNotification" end target 'InsiderNotificationService' do inherit! :search_paths # Pods for InsiderNotificationService pod "InsiderMobileAdvancedNotification" end # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. # use_flipper!(configurations: ['DebugDev', 'Debug', 'ReleaseDev', 'Release', 'DebugQa', 'ReleaseQa']) ENVFILES = { 'Debug' => '$(PODS_ROOT)/../../.env.prod', 'DebugQa' => '$(PODS_ROOT)/../../.env.qa', 'DebugDev' => '$(PODS_ROOT)/../../.env.dev', 'Release' => '$(PODS_ROOT)/../../.env.prod', 'ReleaseQa' => '$(PODS_ROOT)/../../.env.qa', 'ReleaseDev' => '$(PODS_ROOT)/../../.env.dev', } post_install do |installer| react_native_post_install(installer) __apply_Xcode_12_5_M1_post_install_workaround(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| if target.name == 'react-native-config' config.build_settings['ENVFILE'] = ENVFILES[config.name] end config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = "" config.build_settings['CODE_SIGNING_REQUIRED'] = "NO" config.build_settings['CODE_SIGNING_ALLOWED'] = "NO" end end end end # ⬇️ uncomment wanted permissions (don't forget to remove the last comma) setup_permissions([ # 'AppTrackingTransparency', # 'BluetoothPeripheral', # 'Calendars', # 'Camera', # 'Contacts', # 'FaceID', # 'LocationAccuracy', # 'LocationAlways', # 'LocationWhenInUse', # 'MediaLibrary', # 'Microphone', # 'Motion', 'Notifications' # 'PhotoLibrary', # 'PhotoLibraryAddOnly', # 'Reminders', # 'SpeechRecognition', # 'StoreKit' ]) ``` #### `AppDelegate.m`: ```objc #import // DEEP LINK
#import
#import
#import "AppDelegate.h"
#import // GA
#import
#import
#import
#ifdef FB_SONARKIT_ENABLED
#import
#import
#import
#import
#import
#import
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
@import TrackerBlockerFramework;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[FIRApp configure];
[[TrackerBlocker shared] registerServices];
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"myapp" initialProperties:nil];
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];
// Define UNUserNotificationCenter
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
return YES;
}
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for localNotification event
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)(void))completionHandler
{
[RNCPushNotificationIOS didReceiveNotificationResponse:response];
}
//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
}
// DEEP LINK
// Add this inside `@implementation AppDelegate` above `@end`:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
@end
```
Android
Click To Expand
#### Have you converted to AndroidX? - [x] 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 = "30.0.2" minSdkVersion = 21 compileSdkVersion = 33 targetSdkVersion = 33 ndkVersion = "21.4.7075529" kotlin_version = "1.8.0" kotlinVersion = "1.8.0" androidXAnnotation = "1.2.0" androidXBrowser = "1.3.0" } repositories { google() mavenCentral() maven { url "https://developer.huawei.com/repo/" } } dependencies { // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files classpath('com.android.tools.build:gradle:4.2.2') // noinspection GradleDependency classpath('com.google.gms:google-services:4.3.14') // GA classpath('com.google.firebase:perf-plugin:1.4.2') classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" // noinspection GradleDependency classpath('com.google.firebase:firebase-crashlytics-gradle:2.9.2') // Crashlytics classpath 'com.huawei.agconnect:agcp:1.7.1.300' } } allprojects { repositories { 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") } mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. content { excludeGroup "com.facebook.react" } } google() maven { url 'https://www.jitpack.io' } maven { url "https://maven.google.com" } maven { url "https://mobilesdk.useinsider.com/android" } maven { url "https://developer.huawei.com/repo/" } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "kotlin-android" apply plugin: 'com.huawei.agconnect' apply plugin: "com.android.application" apply plugin: "com.google.gms.google-services" apply plugin: "com.google.firebase.crashlytics" apply plugin: "com.google.firebase.firebase-perf" project.ext.envConfigFiles = [ qaDebug : ".env.qa", qaRelease : ".env.qa", devDebug : ".env.dev", devRelease : ".env.dev", anothercustombuild: ".env", ] apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" /** * 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 = true /** * Architectures to build native code for in debug. */ def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") def appVersionName = "${project.APP_VERSION_NAME}".trim() def appVersionCode = Integer.parseInt("${project.APP_VERSION_CODE}".trim()) android { ndkVersion rootProject.ext.ndkVersion compileSdkVersion rootProject.ext.compileSdkVersion project.archivesBaseName = "MyApp-${appVersionName}-${appVersionCode}" defaultConfig { applicationId project.env.get("app_id") minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode appVersionCode versionName appVersionName manifestPlaceholders.appAuthRedirectScheme = 'com.myapp' externalNativeBuild { cmake { cppFlags "" } } resValue "string", "build_config_package", "com.fake.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 { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug if (nativeArchitectures) { ndk { abiFilters nativeArchitectures.split(',') } } } release { // ⚠ Make sure to comment out this line before pushing. // UnCommenting may cause pipelie failure due to double signing. // signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" } } flavorDimensions ".env" productFlavors { qa { manifestPlaceholders.partner = "myappuat" externalNativeBuild { cmake { cppFlags += "-DENV_QA" } } } dev { manifestPlaceholders.partner = "myappuat" externalNativeBuild { cmake { cppFlags += "-DENV_DEV" } } } prod { manifestPlaceholders.partner = "myapp" externalNativeBuild { cmake { cppFlags += "-DENV_PROD" } } } } // 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(com.android.build.OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = defaultConfig.versionCode * 1000 + versionCodes.get(abi) } } } sourceSets { main { jniLibs.srcDirs = ['libs'] } } } apply from: "dependencies.gradle" // 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 = 'myapp' include ':react-native-insider' project(':react-native-insider').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-insider/android') include ':react-native-fs' project(':react-native-fs').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fs/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-gesture-handler' project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android') include ':react-native-reanimated' project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android') include ':react-native-config' project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' ``` #### `MainApplication.kt`: ```kotlin package com.fake.myapp import android.app.Application import android.content.Context import com.facebook.react.* import com.facebook.react.bridge.JSIModulePackage import com.facebook.soloader.SoLoader import com.fake.myapp.secureApiKeys.RNSecureApiKeysPackage import com.fake.myapp.secureRandom.RNSecureRandomPackage import com.fake.myapp.sslPinningConfig.SSLPinningConfigPackage import com.fake.myapp.trackerBlocker.TrackerBlockerRunnerPackage import com.swmansion.reanimated.ReanimatedJSIModulePackage import java.lang.reflect.InvocationTargetException class MainApplication : Application(), ReactApplication { private val mReactNativeHost: ReactNativeHost = object : ReactNativeHost(this) { override fun getUseDeveloperSupport(): Boolean { return BuildConfig.DEBUG } override fun getPackages(): List {
val packages: MutableList = PackageList(this).packages
packages.add(RNSecureRandomPackage())
packages.add(RNSecureApiKeysPackage())
packages.add(SSLPinningConfigPackage())
packages.add(TrackerBlockerRunnerPackage())
return packages
}
override fun getJSMainModuleName(): String {
return "index"
}
@Suppress("DEPRECATION")
override fun getJSIModulePackage(): JSIModulePackage {
return ReanimatedJSIModulePackage()
}
}
override fun getReactNativeHost(): ReactNativeHost {
return mReactNativeHost
}
override fun onCreate() {
super.onCreate()
SoLoader.init(this, /* native exo-package */false)
if (BuildConfig.DEBUG) {
initializeFlipper(this, reactNativeHost.reactInstanceManager)
}
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*/
private fun initializeFlipper(context: Context, reactInstanceManager: ReactInstanceManager) {
try {
/**
* We use reflection here to pick up the class that initializes Flipper,
* since Flipper library is not available in release mode
*/
val aClass = Class.forName("com.fake.myapp.ReactNativeFlipper")
aClass.getMethod(
"initializeFlipper",
Context::class.java,
ReactInstanceManager::class.java
).invoke(null, context, reactInstanceManager)
} catch (e: ClassNotFoundException) {
e.printStackTrace()
} catch (e: NoSuchMethodException) {
e.printStackTrace()
} catch (e: IllegalAccessException) {
e.printStackTrace()
} catch (e: InvocationTargetException) {
e.printStackTrace()
}
}
}
```
#### `AndroidManifest.xml`:
```xml
```
Environment
Click To Expand
**`react-native info` output:** ``` System: OS: macOS 13.6 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 223.63 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.20.2 - /var/folders/l0/7t9zz3t54256c_r3rqbc0rch0000gn/T/yarn--1696665461624-0.7668714027732724/node Yarn: 1.22.19 - /var/folders/l0/7t9zz3t54256c_r3rqbc0rch0000gn/T/yarn--1696665461624-0.7668714027732724/yarn npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm Watchman: 2023.09.04.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.2 - /Users/youshaarshad/.rbenv/shims/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 Android SDK: Not Found IDEs: Android Studio: 2022.3 AI-223.8836.35.2231.10671973 Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild Languages: Java: 11.0.20 - /Users/youshaarshad/.sdkman/candidates/java/current/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.3 => 0.67.3 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **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:** - `16.4.1` - **`Firebase` module(s) you're using that has the issue:** - `Analytics` - **Are you using `TypeScript`?** - `Y` & `4.7.4`
React Native Firebase
andInvertase
on Twitter for updates on the library.