Bisko Android SDK

This service allows you to add Bisko to your Android app. This section of the documentation provides detailed steps on how to succesfully complete this task.

Requirements

Item

Notes

Android Studio

Download & Install Android Studio.

Android 4.4 (API 19)

Your app must be leveraging at least this minimum OS version.

Adding the Bisko SDK

  1. From Android Studio, open your project.

  2. Open settings.gradle if you're using dependency resolution management. Otherwise, open a project-level build.gradle file.

  3. Add the necessary repositories.

  repositories {
    maven {
        url 'https://pkgs.dev.azure.com/gjirafadev/_packaging/AndroidResources/maven/v1'
        }
    }
}
  1. Navigate to the build.gradle app level under the dependencies folder. Add the following code snippet.

  
implementation "tech.gjirafa:bisko:{TAG}"

NOTEReplace {TAG} with the latest version of the Bisko SDK.
  1. Sync Gradle

You have now successfully added the Bisko SDK into your application

Setup

In order to complete the Bisko SDK import process, you must complete the following steps.

  1. Call Bisko.init() on your running activity.

  //Initiation code for applications developed in kotlin
Bisko.init(context = this, propertyId = BISKO_PROPERTY_ID)
  //Initiation code for applications developed in java
Bisko.Companion.init(this, BISKO_PROPERTY_ID);

Additionally you can send extra data which can be used to identify a user within different applications. For example, you can send additional IDs, or other user properties such as gender, age, group etc.

  //Initiation code with user information for applications developed in kotlin
val userProps: HashMap<String, String> = HashMap()
    userProps["Age"] = "33"
    userProps["Gender"] = "Female"
    Bisko.init(context = this, propertyId = BISKO_PROPERTY_ID, userId = "USER_ID_HERE", userProperties = userProps)
  //Initiation code with user information for applications developed in java
Bisko.Companion.init(this, BISKO_PROPERTY_ID, "USER_ID_HERE", new HashMap<String, String>(){{ put("Age", "33"); put("Gender", "Male");}}, true);

As seen from the samples above the init() function expects five parameters:

PARAMETER

DATATYPE

REQUIRED

DESCRIPTION

context

TRUE

Context in which you'll use Bisko SDK.

propertyId

INTEGER

TRUE

The identification number of you property created within your organization.

userId

STRING

FALSE

The user identifier within your website.

userProperties

HASHMAP<STRING,STRING>

FALSE

Extra user properties that you want to be added to the collected data.

useLocation

BOOLEAN

FALSE

Used to specify whether to collect users GeoLocation information; Default value: true

Analytics

This section provides information on how to set up Bisko analytics for your Android app.

Implementing the delegate

The code snippets below provide information on how to execute this process using either Kotlin or Java.

  Bisko.setDelegate(object : PushEventDelegate {
    override fun onRequestStarted(body: String) {
        // When request start with it's body
    }

    override fun onPushEventCompleted(success: Boolean, body: Any?, error: String) {
        // Event response
    }
})
  Bisko.Companion.setDelegate(new PushEventDelegate() {
    @Override
    public void onRequestStarted(@NonNull String body) {
        // When request start with it's body
    }

    @Override
    public void onPushEventCompleted(boolean success, @Nullable Object body, @NonNull String error) {
        // Event response
    }
});

You can also listen for events in a class level. In order to do so, follow these instructions.

  1. On the onCreate() method of your fragment/activity, before invoking Bisko.init(), add the following code snippet.

  Bisko.setDelegate(this)
  Bisko.Companion.setDelegate(this);
  1. Implement the delegate on our class.

  class YourKotlinActivity : AppCompatActivity(R.layout.your_layout), PushEventDelegate {
    ...
}
  public class YourJavaActivity extends AppCompatActivity implements PushEventDelegate {
    ...
}
  1. Override the onRequestStarted() and onPushEventCompleted() methods.

  override fun onRequestStarted(body: String) {
    // When request start with it's body
}

override fun onPushEventCompleted(success: Boolean, body: Any?, error: String) {
    // Event response
}
  @Override
public void onRequestStarted(@NonNull String body) {
    // When request start with it's body
}

@Override
public void onPushEventCompleted(boolean success, @Nullable Object body, @NonNull String error) {
    // Event response
}

Event collection

Standard events are predefined user actions that correspond to common activities, such as reading an article, viewing a product, or watching a video.

All standard events are collected by calling one of the following methods.

  • Invoke Bisko.event() using JSONObject as content

Parameter

Description

type

Your event name

content

Your JSONObject with your content

  • Invoke Bisko.event() using HashMap as content

Parameter

Description

type

Your event name

events

Your HashMap<String,Any> with your content

Collecting an event happening in the application can be as easy as the following:

  // Kotlin
Bisko.event("contentView")
  // Java
Bisko.Companion.event("contentView")

Since the event name is a string, you can send any text that covers your needs:

  // Kotlin
Bisko.event("read")
Bisko.event("view")
Bisko.event("search")
Bisko.event("play")
  // Java
Bisko.Companion.event("read")
Bisko.Companion.event("view")
Bisko.Companion.event("search")
Bisko.Companion.event("play")
The SDK must be initiated before you start collecting the events.

Event parameters

Standard events support properties, which allow you to include an object containing additional information about an event, such as ID, name, type, description etc.

The predefined properties that can be collected for the content where the event happened are:

PROPERTY

DATATYPE

DESCRIPTION

Id

STRING

The identifier of the content.

Name

STRING

The name of the content.

Type

STRING

Type of content, i.e. "video", "news article".

Description

STRING

Description of the content.

Category

ARRAY

A string array of the content categories.

ImageUrl

STRING

The url of the main image of the content.

Value

STRING

Value of content, i.e. for ecommerce "100 $".

Keywords

ARRAY

A string array of keywords related to the content.

Author

STRING

The author of the content.

Quantity

INTEGER

Quantity of the content.

All these properties are optional, so not sending any of them does not pose a problem.

In addition to the predefined properties mentioned above, custom properties that seem relevant to the event can be added to the content object.

All custom properties must be of type string