diff --git a/android/app/build.gradle b/android/app/build.gradle index 566f17dd4..59e9fc646 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -236,6 +236,9 @@ dependencies { implementation project(':reactnativenotifications') implementation project(":reactnativekeyboardinput") implementation project(':@react-native-community_viewpager') + playImplementation project(':@react-native-firebase_app') + playImplementation project(':@react-native-firebase_analytics') + playImplementation project(':@react-native-firebase_crashlytics') implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules diff --git a/android/app/src/foss/java/chat/rocket/reactnative/AdditionalModules.java b/android/app/src/foss/java/chat/rocket/reactnative/AdditionalModules.java new file mode 100644 index 000000000..b7f868cdc --- /dev/null +++ b/android/app/src/foss/java/chat/rocket/reactnative/AdditionalModules.java @@ -0,0 +1,14 @@ +package chat.rocket.reactnative; + +import android.app.Application; + +import com.facebook.react.ReactPackage; + +import java.util.Arrays; +import java.util.List; + +public class AdditionalModules { + public List getAdditionalModules(Application application) { + return Arrays.asList(); + } +} diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java index 12d7c0184..7d224772e 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java @@ -3,38 +3,31 @@ package chat.rocket.reactnative; import android.app.Application; import android.content.Context; import android.os.Bundle; + import androidx.annotation.Nullable; import com.facebook.react.PackageList; -import com.facebook.hermes.reactexecutor.HermesExecutorFactory; -import com.facebook.react.bridge.JavaScriptExecutorFactory; 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 chat.rocket.reactnative.generated.BasePackageList; - -import org.unimodules.adapters.react.ModuleRegistryAdapter; -import org.unimodules.adapters.react.ReactModuleRegistryProvider; -import org.unimodules.core.interfaces.SingletonModule; - -import com.wix.reactnativenotifications.RNNotificationsPackage; +import com.nozbe.watermelondb.WatermelonDBPackage; +import com.reactnativecommunity.viewpager.RNCViewPagerPackage; +import com.wix.reactnativekeyboardinput.KeyboardInputPackage; import com.wix.reactnativenotifications.core.AppLaunchHelper; import com.wix.reactnativenotifications.core.AppLifecycleFacade; import com.wix.reactnativenotifications.core.JsIOHelper; import com.wix.reactnativenotifications.core.notification.INotificationsApplication; import com.wix.reactnativenotifications.core.notification.IPushNotification; -import com.wix.reactnativekeyboardinput.KeyboardInputPackage; -import com.nozbe.watermelondb.WatermelonDBPackage; -import com.reactnativecommunity.viewpager.RNCViewPagerPackage; +import org.unimodules.adapters.react.ModuleRegistryAdapter; +import org.unimodules.adapters.react.ReactModuleRegistryProvider; import java.util.Arrays; import java.util.List; +import chat.rocket.reactnative.generated.BasePackageList; + public class MainApplication extends Application implements ReactApplication, INotificationsApplication { private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), null); @@ -49,17 +42,15 @@ public class MainApplication extends Application implements ReactApplication, IN protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); - if (!BuildConfig.FDROID_BUILD) { - packages.add(new RNNotificationsPackage(MainApplication.this)); - } packages.add(new KeyboardInputPackage(MainApplication.this)); packages.add(new WatermelonDBPackage()); packages.add(new RNCViewPagerPackage()); - // packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider)); List unimodules = Arrays.asList( new ModuleRegistryAdapter(mModuleRegistryProvider) ); packages.addAll(unimodules); + List additionalModules = new AdditionalModules().getAdditionalModules(MainApplication.this); + packages.addAll(additionalModules); return packages; } diff --git a/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java b/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java new file mode 100644 index 000000000..2b3dd08c9 --- /dev/null +++ b/android/app/src/play/java/chat/rocket/reactnative/AdditionalModules.java @@ -0,0 +1,24 @@ +package chat.rocket.reactnative; + +import android.app.Application; + +import com.facebook.react.ReactPackage; +import com.wix.reactnativenotifications.RNNotificationsPackage; + +import java.util.Arrays; +import java.util.List; + +import io.invertase.firebase.analytics.ReactNativeFirebaseAnalyticsPackage; +import io.invertase.firebase.app.ReactNativeFirebaseAppPackage; +import io.invertase.firebase.crashlytics.ReactNativeFirebaseCrashlyticsPackage; + +public class AdditionalModules { + public List getAdditionalModules(Application application) { + return Arrays.asList( + new ReactNativeFirebaseAnalyticsPackage(), + new ReactNativeFirebaseAppPackage(), + new ReactNativeFirebaseCrashlyticsPackage(), + new RNNotificationsPackage(application) + ); + } +} diff --git a/android/settings.gradle b/android/settings.gradle index 26f8adaaf..ed2f78c10 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -10,5 +10,11 @@ include ':reactnativekeyboardinput' project(':reactnativekeyboardinput').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-keyboard-input/lib/android') include ':@react-native-community_viewpager' project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android') +include ':@react-native-firebase_app' +project(':@react-native-firebase_app').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/app/android') +include ':@react-native-firebase_analytics' +project(':@react-native-firebase_analytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/analytics/android') +include ':@react-native-firebase_crashlytics' +project(':@react-native-firebase_crashlytics').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-firebase/crashlytics/android') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' diff --git a/react-native.config.js b/react-native.config.js index 935fa6c85..cbd0de1b6 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -15,6 +15,21 @@ module.exports = { android: null, ios: null } + }, + '@react-native-firebase/app': { + platforms: { + android: null + } + }, + '@react-native-firebase/analytics': { + platforms: { + android: null + } + }, + '@react-native-firebase/crashlytics': { + platforms: { + android: null + } } } };