PepperHQ Developer

The PepperHQ Developer Hub

Hand crafted, customised and bespoke mobile experiences to suit your brand and needs.



Getting started with the Android SDK

Installing the SDK

  • First, request the PepperSdk.jar file from the team at Pepper.
  • Add the JAR file to your Android Studio project

The SDK does not supply the libraries needed to avoid conflicts with your own imports. Therefore you will need to add the following lines to your app's build.gradle file:

compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'

Getting started

Supply the Base URL and App ID

You must supply the SDK with the Base URL to use for all requests:

PepperServiceHelper.BASE_URL = getResources().getString(R.string.baseUrl);

It is a good idea to do this in your Main Activity onResume method or extend the Application and implement in the onCreate method.

REST Communication

The Android SDK makes use of the Retrofit library by Square Inc (, if you are not familiar with this library we highly recommend visiting the website to understand how it works.

User Registration

The registration can take place using either

  • Phone Number and Password
  • Facebook Login

The registration call needs to be provided with a Retrofit Callback:

Callback<UserRegistrationResponse> callback = new Callback<UserRegistrationResponse>() {
  public void success(UserRegistrationResponse userRegistrationResponse, Response response) {
    if (response.getStatus() == 201) {
      // handle success
  public void failure(RetrofitError error) {
    if (error.getKind().equals(RetrofitError.Kind.NETWORK)) {
      // show no network error
      // handle error

You need to pass a UserRegistrationRequest with the request, use the constructor to provide details:

UserRegistrationRequest(firstName.getText().toString(), lastName.getText().toString(), credentials, null);

The Credentials object must be created based on whether the registration is phone number or Facebook:

Phone Number:
Credential credential = new Credential();
Credential credential = new Credential();
credential.setId(id); // Facebook id from Facebook login through Facebook SDK
credential.setToken(accessToken); // token from Facebook login through Facebook SDK

Finally make the call through the PepperSdk

PepperSdk.getInstance(context).registerUser(false, callback, userRegistrationRequest);

User Activation

In the case of phone number and password registrations, the user will receive a SMS with an activation code, this must be used to activate their account with the API. Simply call the following method with a Retrofit Callback<UserActivateResponse>

PepperSdk.getInstance(context).activateLogin(false, callback, mobileNumber, activationCode.getText().toString());

User Login

The login call needs to be provided with a Retrofit Callback<UserLoginResponse>

For phone number logins use:
PepperSdk.getInstance(context).userLogin(true, callback, mobileNumber.getText().toString(), password.getText().toString(), false);
For Facebook logins use:
PepperSdk.getInstance(context).userLogin(true, callback, facebookId, accessToken, true);

Recommended calls following a successful login:

Get User

This call should be used to update the users balance, favourite drinks etc...

PepperSdk.getInstance(context).getUser(true, callback, PepperStorageHelper.getInstance(context).getUserId(), PepperStorageHelper.getInstance(context).getToken());

The Callback returns a User object, the PepperStorageHelper automatically stores the token and userId for you upon successful login.

Get Checkins

This call should be used to find currently active Check-ins for the User:

PepperSdk.getInstance(context).listCheckinsForUser(true, callback, PepperStorageHelper.getInstance(context).getUserId(), PepperStorageHelper.getInstance(context).getToken());

The Callback return a CheckinListResponse response, which contains a list of active check-ins.

Get User Avatar

You should check User object for hasProfilePhoto, if true get the image using the following URL.

String.format("", PepperStorageHelper.getInstance(context).getUserId())

Get Locations

Returns a LocationsResponse object containing a list of Location objects, can be used to populate maps, get nearest locations etc...

PepperSdk.getInstance(context).getLocations(true, callback, PepperStorageHelper.getInstance(context).getToken(), queryParams);

The queryParams is a HashMap, for you convinience a Builder patern has been provided to construct this LocationParams.Builder, in the Builder you can pass optional params such as how many locations to return, and provide lat long to get the list ordered by nearest location.


To check-in to a location use the following method:

  .checkinToLocation(false, callback, PepperStorageHelper.getInstance(context).getUserId(), PepperStorageHelper.getInstance(context).getToken(), location.get_id());

The Callback returns a Checkin object, pass in the Location id you want to check the user into.

Updated about 21 hours ago


Getting started with the Android SDK

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.