This Api is meant for 3rd party integrations
The generated code uses a few Gradle dependencies e.g., Jackson, Volley, and Apache HttpClient. The reference to these dependencies is already added in the build.gradle file will be installed automatically. Therefore, you will need internet access for a successful build.
- In order to open the client library in Android Studio click on
Open an Existing Android Project
.
- Browse to locate the folder containing the source code. Select the location of the CynSMSAPI gradle project and click
Ok
.
- Upon successful import, the project can be built by clicking on
Build > Make Project
or pressingCtrl + F9
.
The following section explains how to use the CynSMSAPI library in a new project.
For starting a new project, click on Create New Android Studio Project
.
Here, configure the new project by adding the name, domain and location of the sample application followed by clicking Next
.
Following this, select the Phone and Tablet
option as shown in the illustration below and click Next
.
In the following step, choose Empty Activity
as the activity type and click Next
.
In this step, provide an Activity Name
and Layout Name
and click Finish
. This would take you to the newly created project.
In order to add a dependency to this sample application, click on the android button shown in the project explorer on the left side as shown in the picture. Click on Project
in the drop down that emerges.
Right click the sample application in the project explorer and click on New > Module
as shown in the picture.
Choose Import Gradle Project
and click Next
.
Click on Finish
which would take you back to the sample application with the refernced SDK.
In the following step first navigate to the SampleApplication > settings.gradle
file and add the line
include ':CynSMSAPILib'
Then navigate to the SampleApplication > app > build.gradle
file and add the following line
implementation project(path: ':CynSMSAPILib')
to the dependencies section as shown in the illustration below. Also add the following packagingOptions.
packagingOptions exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/DEPENDENCIES' }
Finally, press Sync Now
in the warning visible as shown in the picture below.
Once the SampleApplication
is created, a file named SampleApplication > app > src > main > java > MainActivity
will be visible in the Project Explorer with an onCreate
method. This is the entry point for the execution of the created project.
Here, you can add code to initialize the client library and instantiate a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
The generated code and the server can be tested using automatically generated test cases. JUnit is used as the testing framework and test runner.
In Android Studio, for running the tests do the following:
- Right click on SampleApplication > CynSMSAPILib > androidTest > java) from the project explorer.
- Select "Run All Tests" or use "Ctrl + Shift + F10" to run the Tests.
API client can be initialized as following. The appContext
being passed is the Android application Context
.
com.cynojine.sms.Configuration.initialize(appContext);
CynSMSAPIClient client = new CynSMSAPIClient();
The singleton instance of the APIController
class can be accessed from the API Client.
APIController client = client.getClient();
TODO: Add a method description
void createSendSMSAsync(
final String apiKey,
final String to,
final String sms,
final String from,
final APICallBack<String> callBack)
Parameter | Tags | Description |
---|---|---|
apiKey | Required DefaultValue |
set your API_KEY from http://sms.cynojine.com/sms-api/info (user panel) |
to | Required DefaultValue |
the number we are sending to - Any phone number |
sms | Required |
SMS Body |
from | Required |
Change the from number below. It can be a valid phone number or a String |
String apiKey = "xxxxxxxxxxxxx";
String to = "260986";
String sms = "sms";
String from = "from";
// Invoking the API call with sample inputs
client.createSendSMSAsync(apiKey, to, sms, from, new APICallBack<String>() {
public void onSuccess(HttpContext context, String response) {
// TODO success callback handler
}
public void onFailure(HttpContext context, Throwable error) {
// TODO failure callback handler
}
});
Checking SMS Balance
void getBALANCECHECKAsync(
final GetBALANCECHECKInput input,
final Map<String, Object> queryParameters,
final APICallBack<Object> callBack)
Parameter | Tags | Description |
---|---|---|
apiKey | Required |
Get your account balance |
response | Required DefaultValue |
Json Responce |
queryParameters | Optional |
Additional optional query parameters are supported by this method |
GetBALANCECHECKInput collect = new GetBALANCECHECKInput();
String apiKey = "api_key";
collect.setApiKey(apiKey);
String response = "json";
collect.setResponse(response);
// key-value map for optional query parameters
Map<String, Object> queryParams = new LinkedHashMap<String, Object>();
// Invoking the API call with sample inputs
client.getBALANCECHECKAsync(collect, , queryParams, new APICallBack<void>() {
public void onSuccess(HttpContext context, void response) {
// TODO success callback handler
}
public void onFailure(HttpContext context, Throwable error) {
// TODO failure callback handler
}
}
);