This section describes how to initialize a container for the Android and iOS platforms.
Before accessing MiniApps that are stored within an Electrode Native container, the container needs to be initialized.
Initialization of a Container should ideally take place during startup of your mobile application. If you are using a class extending Application, you should place the container initialization call in the
onCreatemethod of this class. If you are not using an Application class to initialize all libraries used by your mobile application, you should place the container initialization code wherever appropriate. It's best to have it initialized as soon as possible in the application lifecycle.
The initialization of a container is done as a single call of the
initialize staticmethod of the
this /* Application instance */,
/* Additional plugins configuration here */);
The first parameter to this method is the
Applicationinstance. In the sample call above, we use
thisas the call is made from an
Applicationextending class. The second parameter is the configuration of the container and React Native. In the sample above, we enable React Native developer support. In the sample we make use of
BuildConfig.DEBUGto enable developer mode for debug builds only. You can adapt it for your application needs.
initializemethod might also contain additional parameters. Respectively, one parameter per plugin configuration. Not all plugins (APIs or third-party native modules) are configurable, so most of them (>90%) won't add an extra parameter to the initialize method. One configurable plugin is
react-native-code-pushfor example, as you need to pass a
deployment keyto initialize this plugin, and it also has a debug mode that you can enable or disable.
Before accessing MiniApps stored within an Electrode Native container, you need to initialize the container. In iOS, we prefix our platform-specific files with
Initialization of a Container should ideally take place during startup of your mobile application. Ideally it should take place in your
didFinishLaunchingWithOptions:method. Otherwise, you should call the container initialization wherever appropriate. It's best to have it initialized as soon as possible.
Initialization of Container is performed through the static method
let containerConfig = ElectrodeContainerConfig()
containerConfig.debugEnabled = RnDevSupportEnabled
ElectrodeContainerConfig *containerConfig = [[ElectrodeContainerConfig alloc] init];
containerConfig.debugEnabled = RnDevSupportEnabled;
The first parameter is an implementation of the
ElectrodePluginConfigprotocol we provide through
ElectrodeContainerthat allows you to configure for both
ElectrodeContainerand React Native. In the sample above we use
RnDevSupportEnabled, a static boolean constant, to decide if developer support should be enabled or not. You can adapt it for your application needs.
startWithConfigurations:method might also take additional parameters such as the implementation of
ElectrodePluginConfigfor additional plugins, depending on your plugin dependencies. Specifically, one parameter per plugin configuration. Note Not all plugins (APIs or third party native modules) are configurable, so most of them (>90%) won't add an extra parameter to the
initializemethod. One configurable plugin is
react-native-code-pushfor example, as you need to pass a deployment key to initialize this plugin, and it also has a debug mode that you can enable or disable.