Skip to content

Zamplia/zampliasdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Zamplia-Android-SDK

Migration guide

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.0'
    ...
   }

And synchronize the project with the gradle files.

Quick Guide

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.

Implement Zamplia in your code

  1. 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;
  1. 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);
  1. 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").build();

After creating instance of Params to get the offer use the below code snippet :

  ZampliaApp.showAvailableSurveys(this, mParams, this);
  1. 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

Zamplia SDK lifeCycle methods :

  1. If Zamplia SDK is failed while initialization process then this event will receive. Ex.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMInitializationFailed() {
          ...
      }
  }
  1. 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) {
          ...
      }
  }
  1. 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) {
          ...
      }
  }
  1. You can be notified when Zamplia survey not available for the user.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMSurveyNotAvailable() {
          ...
      }
  }
  1. 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) {
          ...
      }
  }
  1. You can be notified if user has closed the offer/survey window.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMWindowClosed() {
          ...
      }
  }
  1. 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() {
          ...
      }
  }
  1. We will notify when user gets complete the survey. We will send here SurveyData as well where ID and reward value you will receive.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMSurveyCompleted(SurveyData surveyInfo){
          Log.e("SurveyId", surveyInfo.getSurveyId());
          Log.e("RewardValue", surveyInfo.getCpi()); 
          ...
      }
  }
  1. We will notify if user get terminated.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMTerminated() {
          ...
      }
  }
  1. We will notify if user traced in security fails.
  public class MainActivity extends AppCompatActivity implements ZampliaCallbacks {
      @Override
      public void onZAMSecurityFailed() {
          ...
      }
  }
  1. 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() {
          ...
      }
  }