The NetFUNNEL Android Agent controls the traffic of web views output from within your application, protecting your service infrastructure and ensuring a stable user experience for your visitors.
- Service: A target website (URL) to control traffic in conjunction with NetFUNNEL.
NetFUNNEL Agent Features
The NetFUNNEL Android Agent is a library that helps you control traffic when the URL of your main domain connected to NetFUNNEL is visited from within a mobile application you have built.
The detailed functions of the agent are as follows
- Responsible for communication between the main domain connected to NetFUNNEL and Center API / NetFUNNEL server and controls traffic when the registered URL is called from within the application.
- It collects data about device status information for EUM (End User Monitoring) function and the duration of the set section. It automatically collects data when you make a request to NetFUNNEL, but you can use the API directly to measure the desired segment.
Requirements
- Supports Java 1.8 or higher and Android SDK 23 (Marshmallow) or higher.
-
Gradle's dependency contains complieOnly and 'com.squareup.okhttp3:okhttp:3.0.0'.
-
Please be aware of the crash.
-
How to install the NetFUNNEL Android Agent
Requirements
1. Download the library and add it to Gradle.
- Sample code
implementation files('libs/surffy-agent_aos_latest.aar')
2. Initialize using the nfInit function before using the Netfunnel function.
- Kotlin
fun nfInit() {
/*
* 1. AppName, 2. tenant API Server URL, 3. tenant Netfunnel Server URL, 4. netfunnel setting server URL,
* 5. eum Server URL, 6. activity(waiting page on this activity), 7. context
*/
Netfunnel.Init(
"MyAppName",
"{tenant API URL}",
"{tenant NF URL}",
"{nf-setting URL}",
"{eum URL}",
this,
this.baseContext
)
}
- Java
public void nfInit() {
/*
* 1. AppName, 2. tenant API Server URL, 3. tenant Netfunnel Server URL, 4. netfunnel setting server URL,
* 5. eum Server URL, 6. activity(waiting page on this activity), 7. context
*/
Netfunnel.Init(
"MyAppName",
"{tenant API URL}",
"{tenant NF URL}",
"{nf-setting URL}",
"{eum URL}",
this,
this.getBaseContext()
);
}
Implementing the NetFUNNEL Agent
After completing the prerequisite work, you may need to follow additional integration work depending on the environment or purpose for which you are using the service.
- API method that injects code directly where NetFUNNEL applies.
- Automation method that detects URL requests and applies NetFUNNEL.
API Method
1. Implement an AgentInterface that defines a response to the NetFUNNEL feature.
- Kotlin
var myInterface = object : AgentInterface() {
override fun onSuccess() {
// call when user allow access or netfunnel server response error
object : Thread() {
override fun run() {
/*
* to do what you want to after using netfunnel
*/
}
}.start()
}
override fun onCancel(_cancelURL: String) {
// call when user cancel
object : Thread() {
override fun run() {
}
}.start()
}
override fun onFail() {
/*
* activity is null, internet not connected
*/
}
override fun nfLog(_message: String) {
/*
* this function get the process log about library.
* if you want to collect or check process, use this
* like DLog.d(_message)
*/
}
}
- Java
AgentInterface myInterface = new AgentInterface() {
@Override
public void onSuccess() {
// This function is where the operation is implemented after the wait time check is completed and the entry is allowed.
new Thread() {
@Override
public void run() {
/*
* to do what you want to after using netfunnel
*/
}
}.start();
}
@Override
public void onCancel(String _cancelURL) {
if( _cancelURL == "" ) {
return;
}
}
@Override
public void onFail() {
/*
* activity is null, internet not connected
*/
}
@Override
public void nfLog(String _message) {
/*
* this function get the process log about library.
* if you want to collect or check process, use this
* like DLog.d(_message)
*/
}
};
2. Call the nfStart function at the section where you want to start the Netfunnel function.
- Kotlin
fun myAction() {
Netfunnel.nfStart("{segment URL}", myInterface)
}
- Java
public void myAction() {
Netfunnel.nfStart("{segment URL}", myInterface);
}
Automation method
When generating the OkHttp requests you want to track, add the following interceptor class.
- Kotlin
// OKHttp
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(NFInterceptor())
.build
// Retrofit
val retrofit = Retrofit.Builder()
.client(okHttpClient)
.baseUrl("https://example.com")
.build()
- Java
// OKHttp
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.addInterceptor(new NFInterceptor())
.build();
// Retrofit
Retrofit retrofit = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl("https://example.com")
.build();
The automated method works asynchronously and does not support callback functions such as onSuccess.
If an entry is denied, such as by a user abort or a server lock, the response code is returned as 900.
Anomaly Action Defense
The following measures are in place to defend user's anomaly action.
- You can try to connect by switching to airplane mode and disconnecting from the server.
- Call onCancel function when airplane mode is switched.
- You can try to access by exploiting the go-back function loophole.
- Call onCancel function when going back.
- You can try to connect by hitting the button repeatedly to cause a malfunction.
- It checks the call in units of 500 ms to prevent repeated input.
Once you've installed the agent, read the Android Agent Feature Introduction for a detailed feature guide.
Comments
0 comments
Please sign in to leave a comment.