Get the Android SDK
First, you should add the Safous WAAP Android SDK to your project. Visit WAAP Admin Portal to get the latest version of our SDK.
Adding the SDK to Your Project
After obtaining the SDK, insert it into your project's app/libs
directory (<project>/app/libs
) in your Android project.
Embedding the SDK in the Gradle Module
Now, open your build.gradle
file (<project>/build.gradle
) in Android Studio. Then, in the root-level Gradle file, include the SDK files that you have obtained as dependencies. The syntax is provided below:
implementation files('libs/SafousWaap.aar')
Pre-requisition
Before you configure the Android SDK, make sure you already have the certificate for authentication to accessing the environment and configuration file in .ini format. Below is the steps for set the certificate and safouswaap.ini file configuration on your project.
Generate .p12 file
- Download the certificate with .p12 format. If you have not generate the Trusted Certificate, you can create it in Safous portal dashboard. More info for how to generate the certificate provided here.
- Put the certificate on your project. Specifically in assets folder in main directory.
(<project>/app/src/main/assets).
Set safouswaap.ini file configuration
- Find out the directory path of your project. You can check it in your codebase.
String path = getApplicationContext().getFilesDir().getAbsolutePath();
- Next, save the result code of directory path and go to WAAP Admin Portal. There, you need to input the passphrase certificate, also directory path to generate and download the safouswaap.ini file configuration. You can access the portal here.
passphrase : <certificate_passphrase>
path : /data/user/0/<your_project_package>/files/<certificate_name>.p12 - After downloading the safouswaap.ini file, put the certificate on your project. Specifically in Assets folder in main directory.
(<project>/app/src/main/assets).
Setup Environment
For this section, we will call function setupEnv in the SDK. Before that, you have to setup the path for certificate in your Activity class. Now start using the Android SDK. First import the ApiProtection java class from SDK and put it on your Activity class.
import com.safous.waap.ApiProtection;
Then you need to initialized new variable in your Activity class. This variable instance to ApiProtection java class. So it can inherit all the values in SDK to be used in your Activity class.
public static ApiProtection protection;
Next you put the ApiProtection variables and declare it on your Activity class.
protection = new ApiProtection(getApplicationContext());*note: getApplicationContext are needed to be Context extension in your Activity Class
Create the file variable to get the safouswaap.ini file path. In pre-requisitiion section, you already got the path directory of the project. merge it with safouswaap.ini file.
String path = getApplicationContext().getFilesDir().getAbsolutePath();
.
.
.
File inifile = new File(path+"/safouswaap.ini");
Now declare the setupEnv and set the parameters with context and file path.
protection.setupEnv(getApplicationContext(),inifile.getAbsolutePath())
It is all to setup environment and configuration. Next you can use Registration and Transaction modules on this Android SDK. As a note, you still can calling the functions in Registration and Transaction modules from the Android SDK, however it will not work before you setup the environment first.