IMQA SDK Installation Guide_Cordova provides instructions for applying IMQA SDK in the Cordova environment.
After applying the IMQA agent code with reference to the IMQA MPM Installation Guide, please follow further the instructions of this document.
1. 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
2. Adding authority to the Android Manifest
You have to grant Internet authority to upload occurred crash information to AndroidManifest.xml.
How to add IMQABridge may vary depending on development using Cordova.
3.1. WebView HTTP request
Setting the web server
If you want to collect WebView data, you need to embed the IMQA WebView JavaScript library into a web page that supports WebView. You can download the file and serve it directly from your web server. (We recommend importing it directly to avoid CORS issues.)
Inserting a WebView file
<!-- IMQA Webview Agent(ver. 1.1.3 earlier) -->
<script type="text/javascript" src="https://imqawebviewagent.blob.core.windows.net/agent/webview-agent-1.1.2.js"
crossorigin></script>
// If you want to apply it as a min file:
<script type="text/javascript" src="https://imqawebviewagent.blob.core.windows.net/agent/webview-agent-1.1.2.min.js"
crossorigin></script>
..
private static void exposeJsInterface(WebView webView, CordovaBridge bridge) {
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
LOG.i(TAG, "Disabled addJavascriptInterface() bridge since Android version is old.");
// Bug being that Java Strings do not get converted to JS strings automatically.
// This isn't hard to work-around on the JS side, but it's easier to just
// use the prompt bridge instead.
return;
}
SystemExposedJsApi exposedJsApi = new SystemExposedJsApi(bridge);
// Inserting WebView Interface (ImqaBridge required)
webView.addJavascriptInterface(new io.imqa.mpm.network.webview.WebviewInterface(),"ImqaBridge");
webView.addJavascriptInterface(exposedJsApi, "_cordovaNative");
}