Getting Started

Install the Referd Android SDK into your app

Referd's Android SDK enables you to use the show Referd user profile in your app, track app user events, integrate referrals and display Referd's in-app push notifications.

Setting up Referd SDK

Follow the below steps to start installing Referd's Android SDK to your app.

Add JitPack repository to your project's build.gradle (or settings.gradle if you're on newer versions) file.

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Add the following dependency to the application's build.gradle file to import Referd's SDK into your project.

dependencies {
    ...
    implementation 'com.github.gameballers:gb-mobile-android:1.2.10'  
}

Make sure that you added the INTERNET permission in your application's AndroidManifest.xml file as follows:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
    ...
    <uses-permission android:name="android.permission.INTERNET" />
    ...
</manifest>
    

To install Firebase Google Play Services dependencies

The SDK uses Firebase Dynamic Links to track referrals and Firebase Messaging for sending push notifications, you'll need to add the following dependencies.

dependencies {
    ...
    // Make sure to include this dependency even if you won't include Firebase Messaging
    implementation platform('com.google.firebase:firebase-bom:<latest_version>')
    // Firebase Dynamic Links only - must be included
    implementation "com.google.firebase:firebase-dynamic-links"    
    // Firebase Messaging only - optional depending on whether or not you want to use FCM
    implementation 'com.google.firebase:firebase-messaging'  
}

For the latest Firebase SDK (BOM, Cloud Messaging, Deep Links, and Google Services) versions check their release notes.

You also need to add google-services plugin to your application.

App's build.gradle file:

plugins {
    ...
    id 'com.google.gms.google-services'
}

Project's build.gradle file:

buildscript{
    ...
    dependencies {
        ...
        classpath 'com.google.gms:google-services:<latest_version>'

    }
}

Don't forget to include your google-services.json to your app root after registering it to a Firebase project.

Follow this tutorial to learn more on how to register your Android application to Firebase.

Initialize Refer SDK

Create a GameballApp instance

o create a GameballApp instance you need to call the getInstance method and pass it a Context instance of the current Activity holding the GameballApp.

GameballApp gameballApp = GameballApp.getInstance(getApplicationContext());

Initialize GameballApp Instance

To initialize GameballApp instance in your application class, use the init method which takes the following parameters:

Parameter

Type

Required

Description

APIKey

string

Yes

Client API key

lang

string

No

Your platform language preference to view Referd Widget with.

Note: The language provided should be as per configured languages in your account. If not provided the Referd profile widget will be shown with your account default language

Example: "en", "fr".

// Using the instantiated instance of GameballApp
gameballApp.init("{{your API Key}}", "{{lang}}", "{{your Platform name}}", "{{your Shop name}}");

//You can access the init method directly as follows
GameballApp.getInstance(getApplicationContext()).init("{{your API Key}}", "{{lang}}", "{{your Platform name}}", "{{your Shop name}}");

Initialize Firebase Push Notifications

To be able to use Firebase Push Notifications feature through Referd you'd need to first initialize firebase device token by calling the following method right after the init method or before the registration of the user.

// Using the instantiated instance of GameballApp
gameballApp.initializeFirebase();

Last updated