Back to top

Surf SDK Documentation

This is an installation guide for getting Surf’s Android SDK working within your Android app.

Authentication

This documentation will reference an api_key, needed to initialize the Surf SDK. You can find your api_key on your profile edit page on http://index.appbackr.com/user/edit. Furthermore, for the Gradle Dependency, you will need a username and password. This currently can only be done manually, so please contact us to generate one for you via email.

Dependencies

Please add the following dependency to your app gradle file:

repositories {
   maven {
       credentials {
           username 'your_given_username'
           password 'your_given_password'
       }
       url "https://surf-sdk-repo-158610.appspot.com"
   }
}

dependencies {
    compile 'com.surfsup:sdk:1.+'
}

Implementation

Initialize

Start off by calling the next function on your application start, or when you find it appropriate to instantiate the Surf SDK:

Surf.init(Context, "your_api_key");

Enable Permissions

Our SDK requires 3 permissions to be enabled, and depends on which android version the user is running.

Note that the User is not forced to give these permissions. However, each adds unique and useful intelligence to our User-Companionship System, allowing us to identify more contextually-aware Moments for the User.

Location

If you haven’t implemented this into your app yet, you can ask for permission by adding the following code:

Surf.requestLocationPermission(Activity);

Draw Over Other Apps

The following code will send the user to the settings screen to enable this permission:

Surf.requestDrawOverAppPermission();

App Usage

The following code will send the user to the settings screen to enable this permission:

Surf.requestUsageAccess(Activity);

Testing

For internal testing to see whether notifications work, you can fire them manually by using the following code:

Surf.sendTestNotification(Activity);

Note: on Android 6.0 and up, if you don’t have draw over apps permission given, you won’t receive a notification.

Generated by aglio on 29 Mar 2017