IMQA SDK Installation Guide_React_Native provides instructions for applying IMQA SDK in the React Native environment.
After applying the IMQA agent code with reference to the IMQA MPM Installation Guide, please follow further the instructions of this document.
1. Common
MPM Module install
To apply IMQA SDK in the React native environment, execute the command below to install the package.
When Using npm Command
// npm install imqa-react-native-agent --save
When Using yarn Command
yarn add imqa-react-native-agent
2. Installing Gradle plugin
In the “app.gradle” file, add “imqa-mpm-injector” to the “dependencies” block in the "buildscript" followed by “plugin” at the top. This is typically located in “<project_dir>/app/build.gradle”.
The gradle file should be synchronized after updating the file.
...
project.home=Path of project (ex:/user/workspace/project1)
#Add only Kotlin project
project.kotlin.path=$PROJECT_HOME/app/build/tmp/kotlin-classes
#Add only Java project
project.java.path=$PROJECT_HOME/app/build/intermediates/javac/debug/classes
#Path to built manifest file
project.manifest.path=$PROJECT_HOME/app/build/intermediates/merged_manifest/debug/AndroidManifest.xml
#gradle action
project.task.execute=:assemble
3. Adding authority to the Android Manifest
You have to grant Internet authority to upload occurred crash information to AndroidManifest.xml.
4. Inserting the IMQA initialization code into the source code
Writing the IMQA start code
The code should be inserted into the application class, not activity.
At this time, insert the copied “Project Key” value into “PROJECT_KEY”.
MyApplication.java
...@OverridepublicvoidonCreate() { super.onCreate();io.imqa.core.IMQAOption imqaOption =new io.imqa.core.IMQAOption();imqaOption.setBuildType(false);imqaOption.setUploadPeriod(true);imqaOption.setKeepFileAtUploadFail(false);imqaOption.setDumpInterval(10000);imqaOption.setFileInterval(5);imqaOption.setHttpTracing(true);imqaOption.setRemoteControl(true);io.imqa.mpm.IMQAMpmAgent.getInstance().setOption(imqaOption) // Sets an option to decide the MPM operation method..setContext(this,BuildConfig.FLAVOR) // Initializes the application context. (Insert an empty string if there is no flavor).setProjectKey("PROJECT_KEY") // Sets the project key of the IMQA MPM client..init(); // Initializes and executes the registered option....}...
MyApplication.kt
...overridefunonCreate() {super.onCreate()val imqaOption : IMQAOption= io.imqa.core.IMQAOption() imqaOption.setBuildType(false) imqaOption.setUploadPeriod(true) imqaOption.setKeepFileAtUploadFail(false) imqaOption.setDumpInterval(10000) imqaOption.setFileInterval(5) imqaOption.setHttpTracing(true) imqaOption.setRemoteConfig(true) io.imqa.mpm.IMQAMpmAgent.getInstance() .setOption(imqaOption) // Sets an option to decide the MPM operation method. .setContext(this, BuildConfig.FLAVOR) // Initializes the application context. (Insert an empty string if there is no flavor) .setProjectKey("PROJECT_KEY") // Sets the project key of the IMQA MPM client. .init(); // Initializes and executes the registered option....}...
MPM Mode Option
You can change the IMQA MPM execution options using parameters or options. Check the execution options in Android MPM Configuration Options.
Shortcut mode
You can initialize IMQA MPM using the shortcut mode.
MyApplication.java
...override fun onCreate() { super.onCreate()io.imqa.mpm.IMQAMpmAgent.getInstance() .setContext(this, BuildConfig.FLAVOR) // Initializes the application context. (Insert an empty string if there is no flavor)
.setProjectKey("PROJECT_KEY") // Sets the project key of the IMQA MPM client..init() // Initializes and executes the registered option....}...
MyApplication.kt
...overridefunonCreate() {super.onCreate() io.imqa.mpm.IMQAMpmAgent.getInstance() .setContext(this, BuildConfig.FLAVOR) // Initializes the application context. (Insert an empty string if there is no flavor)
.setProjectKey("PROJECT_KEY") // Sets the project key of the IMQA MPM client. .init() // Initializes and executes the registered option....}...
⚠️HTTPS (API level > 27)
The HTTPS request is required from Android API level 28 and above due to the enhanced network security policy. The following measures are needed to meet the requirement:
Authenticated HTTPS request
Request authenticated HTTPS to the IMQA server to collect the data normally.
You can use Zstandard, which is an algorithm enabling more secure and efficient data compression, instead of the typical gzip. To use it, you need the following settings:
Setting the MPM Mode Option
You can set whether to use Zstd in the settings when inserting the IMQA startup code.
MyApplication.java or MyApplication.kt
...imqaOption.setCompressZstd(true);...
Add Zstd Library
In the “app.gradle” file, add the “zstd-jni” aar library to the “dependencies” block in “buildscript”.
ASM
Conflict may occur with the library using ASM.
APK Repackaging
Source line information disappears while repackaging the APK. The auto-insert function should be executed during compilation, in order to include line information.
Collecting library information
The auto-insert function is not executed in the class file added to the library. The auto-insert function should be executed while repackaging the API, in order to collect information on what is executed in the library.
6. Settings required for the installation-type
Any client who selects an IMQA installation-type must set the collection server.
MyApplication.java
...@OverridepublicvoidonCreate() { super.onCreate();io.imqa.core.IMQAOption imqaOption =new io.imqa.core.IMQAOption();/* * Default value: 'https://collector.imqa.io' * Sets the MPM server URL. * String: Server information */imqaOption.setServerUrl('https://(IPAddress)');io.imqa.mpm.IMQAMpmAgent.getInstance().setOption(imqaOption) // Sets the option to decide the MPM operation method. .setContext(this, BuildConfig.FLAVOR) // Initializes the application context. (Insert an empty string if there is no flavor)
.setProjectKey("PROJECT_KEY") // Sets the project key of the IMQA MPM client..init() // Initializes and executes the registered option....}...