Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
mavenCentral()
}
}
Next, add the following to the dependencies closure:
dependencies {
implementation 'com.zamplia:zampsdk:1.0.7'
...
}
And synchronize the project with the gradle files.
1. Obtain a Publisher Account.
2. Download and implement ZampliaSDK.
3. Sync app module with your gradle files.
4. Embed Zamplia in your code and initialize SDK.
5. Implement ZampliaCallbacks to listen events.
6. Use Environment.PRODUCTION before publishing your app to Google Play Store.
7. Request your sales manager for your account to get verify.
- Import Zamplia Classes
import com.zamplia.zampliasdk.ZampliaApp;
import com.zamplia.zampliasdk.builder.Params;
import com.zamplia.zampliasdk.callback.Environment;
import com.zamplia.zampliasdk.callback.SurveyData;
import com.zamplia.zampliasdk.callback.ZampliaCallbacks;
- Initialize Zamplia SDK
After syncing your project with gradle files and importing Zamplia SDK classes you can easily initialize Zamplia SDK.
To initialize, use the following code snippet in onCreate method of your activity.
Use Environment Enum for sandbox/production.
ZampliaApp.getInstance().initialize(this, Environment.PRODUCTION);
- Show Offer
Create Params instance with the below code snippet. Here, you need to pass API-KEY that is provided to you by Zamplia platform.
You have to use sandbox key with sandbox environment and production key with production enviornment.
Here you have to set Platform and transaction Id (session id to track the user).
Code snippet as below :
Params mParams = new Params.Builder("API-KEY")
.setPlatform("Android")
.setTransactionId("SESSON-ID")
.setUserId("Unique-User-ID")
.build();
After creating instance of Params to get the offer use the below code snippet :
ZampliaApp.showAvailableSurveys(this, mParams, this);
- Get Events from Zamplia SDK
We have the following listeners. To use this you have to implement ZampliaCallbacks interface in your activity.
AppCompatActivity implements ZampliaCallbacks
- If Zamplia SDK is failed while the initialization process then this event will receive. Ex.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMInitializationFailed() {
...
}
}
- If Offers are not enabled in any specific cultures. Ex.
Let's assume that Zamplia has not Enabled your users to take offers in USA and your user is from USA than this will receive with error message.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMCultureNotEnabled(String message) {
...
}
}
- If Zamplia SDK has traced or facing any loading error than this will be invoked with error.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMInternalServerError(String message) {
...
}
}
- You can be notified when Zamplia survey not available for the user.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMSurveyNotAvailable() {
...
}
}
- We will notify you when user start survey with Survey data where you can get ID and reward value of survey.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMUserOpenedSurvey(SurveyData surveyData) {
...
}
}
- You can be notified if user has closed the offer/survey window.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMWindowClosed() {
...
}
}
- You can be notified if user has left the current survey in middle and closed the window.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMUserRejectedSurvey() {
...
}
}
- We will notify when user gets complete the survey. We will send here SurveyData as well where ID and reward value you will receive. You can get reward points by calling surveyInfo.getCpi() in this you will get a decimal number in USD currency. for example 1.5 cpi = 1.5 USD. You can just convert it to points as you've asked. for example 1.5 * 100 = 150 points.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMSurveyCompleted(SurveyData surveyInfo){
Log.e("SurveyId", surveyInfo.getSurveyId());
Log.e("RewardValue", surveyInfo.getCpi());
...
}
}
- We will notify if user get terminated.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMTerminated() {
...
}
}
- We will notify if user traced in security fails.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMSecurityFailed() {
...
}
}
- We will notify if user has participated in the survey and has tracked in Quota requirements.
public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
@Override
public void onZAMQuotaFull() {
...
}
}