vn-verdnaturachat/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java

88 lines
3.1 KiB
Java
Raw Normal View History

package chat.rocket.reactnative;
2017-08-03 18:23:43 +00:00
2019-03-12 16:23:06 +00:00
import android.app.Application;
import android.util.Log;
import android.content.Context;
import android.os.Bundle;
2019-03-12 16:23:06 +00:00
import com.facebook.react.PackageList;
import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
2019-03-12 16:23:06 +00:00
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
2017-08-03 18:23:43 +00:00
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.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 io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage;
import io.invertase.firebase.perf.RNFirebasePerformancePackage;
2019-03-12 16:23:06 +00:00
import java.util.Arrays;
import java.util.List;
2017-08-03 18:23:43 +00:00
2019-03-12 16:23:06 +00:00
public class MainApplication extends Application implements ReactApplication, INotificationsApplication {
private final ReactModuleRegistryProvider mModuleRegistryProvider = new ReactModuleRegistryProvider(new BasePackageList().getPackageList(), Arrays.<SingletonModule>asList());
2019-03-12 16:23:06 +00:00
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
2019-03-12 16:23:06 +00:00
@Override
2017-08-03 18:23:43 +00:00
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new RNFirebaseCrashlyticsPackage());
packages.add(new RNFirebaseAnalyticsPackage());
packages.add(new RNFirebasePerformancePackage());
packages.add(new KeyboardInputPackage(MainApplication.this));
packages.add(new RNNotificationsPackage(MainApplication.this));
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
return packages;
}
@Override
2019-03-12 16:23:06 +00:00
protected String getJSMainModuleName() {
return "index";
2017-08-03 18:23:43 +00:00
}
2019-03-12 16:23:06 +00:00
};
2017-08-03 18:23:43 +00:00
2019-03-12 16:23:06 +00:00
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
2019-03-12 16:23:06 +00:00
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
@Override
public IPushNotification getPushNotification(Context context, Bundle bundle, AppLifecycleFacade defaultFacade, AppLaunchHelper defaultAppLaunchHelper) {
return new CustomPushNotification(
context,
bundle,
defaultFacade,
defaultAppLaunchHelper,
new JsIOHelper()
);
}
2017-08-03 18:23:43 +00:00
}