Initialize Gameball Player Profile

Show your players's profile including all details and progress on your Android app.

Showing the GameBall widget on your mobile application is slightly different than showing it on the website. You have two options; first, if you want to design your customer interface, you will use our set of REST APIs. To know more information, you can follow this guide. The other option as this section elaborates, is through using our android SDK.

Using the SDK, you can open the Gameball player profile from a button in your app, programmatically when someone does something, or from a persistent button that sits over your app’s UI.

When you trigger the Gameball player profile, your player is presented with a home screen. This is configurable inside Gameball to change how it looks and what’s presented.

From there, your player can check his progress across different Gameball programs as per your configurations.

Showing Gameball Profile

To show the Gameball player profile that contains the user details, user challenges, and the leaderboard use showProfile() SDK method.

Parameter

Type

Required

Description

Activity

Activity

Yes

Current activity instance holding the GameballApp which will be used in showing the Player's profile.

PlayerUniqueId

String

Yes

Unique identifier for the player in your database.

Could be database ID, random string, email or anything that uniquely identifies the player.

openDetail

String

No

hideNavigation

Boolean

No

gameballApp.showProfile(this, "{{playerUniqueId}}", "{{openDetail}}", "{{hideNavigation}}");

Use showProfile as a parameter to collect the activity or the fragment you are going to show the profile in. Just create a button and call this method in the onClick() method of this button.

Change Profile Widget language

changeLanguage(String language)

Use changeLaguage SDK method to change the widget language.The language provided should be as per configured languages in your account. If not provided the Gameball profile widget will be shown with your account default language

Example: "en", "fr".

Register/Update Player

You should register your players with Gameball. This can be done using registerPlayermethod which can be used to create or update the player details at Gameball. Ideally, it is called when your login or register network call is successful.

Parameter

Type

Required

Description

PlayerUniqueId

String

Yes

Unique identifier for the player in your database.

Could be database ID, random string, email or anything that uniquely identifies the player.

PlayerEmail

String

No

Player's unique Email address.

PlayerMobile

String

No

Player's unique Mobile number.

PlayerAttributes

object

No

PlayerAttributes is a builder class with set of properties that you want to set for the player.

Activity

Activity

Yes

Current activity instance holding the GameballApp which will be used in detecting the referal code from the dynamic link.

Intent

Intent

Yes

An intent instance that will be used in combination with the Activity to detect the referal code from the dynamic link.

CallBack

function

No

Callback is used for providing the developer with the response status and payload.

Everytime the SDK is initialized with a new playerUniqueId , the player profile is created or updated at Gameball side. You may consider enriching your Gameball's player profile with attributes that are not avialable to the UI by using server side Create\Update Player API

Choose an Unchangeable Player Unique ID

Gameball user profile gets created using the playerUniqueId. It is highly recommended to have the unique ID as an identifier that would NEVER be changed. If this unique ID changes for a given player, you risk losing all original data for that player and hence losing their points and rewards on Gameball. Accordingly, it is NOT recommended to use email address or mobile number as the unique ID as both can be changed by the user at anytime.

PlayerAttributes Object

PlayerAttributes is a builder class that helps in creation of the PlayerAttributes with the common attributes mentioned below, all of these attributes are optional to use.

MethodParameter NameType

withDisplayName

displayName

string

withFirstName

firstName

string

withLastName

lastName

string

withEmail

email

string

withGender

gender

string

withMobileNumber

mobileNumber

string

withDateOfBirth

dateOfBirth

string

withJoinDate

joinDate

string

withPreferredLanguage

preferredLanguage

string (ex: en, fr, ar)

withCustomAttribute

(key, value)

(string, string)

withAdditionalAttribute

(key, value)

(string, string)

Note that if you set a Preferred Language, it will override the language value provided in the init method. If neither were provided, the device's default locale will be used.

You can find the complete list of Player Attributes here, if its not included in the PlayerAttributes Builder you can add them as Key/Value pairs using withAdditionalAtribute builder method and it will automatically added upon request.

An example to create PlayerAttributes object

PlayerAttributes playerAttributes = new PlayerAttributes.Builder()
        .withDisplayName("John Doe")
        .withFirstName("John")
        .withLastName("Doe")
        .withMobileNumber("0123456789")
        .withPreferredLanguage("en")
        .withCustomAttribute("{key}", "{Value}")
        .withAdditionalAttribute("{key}", "{Value}")
        .build();

The previous example will return an object of PlayerAttributes with the configured attributes.

Register the Player

Using the previously created GameballApp instance or by creating a new one, call the RegisterPlayer() method as shown below

gameballApp.registerPlayer(
    "{uniquePlayerId}", 
    playerAttributes, 
    this, 
    this.getIntent(), 
    new Callback<PlayerRegisterResponse>() {
        @Override
        public void onSuccess(PlayerRegisterResponse playerRegisterResponse) {
            // TODO Handle on success result.
        }
    
        @Override
        public void onError(Throwable e) {
            // TODO Handle on failure result.
        }
});

//Overloaded with Email and Mobile Number
gameballApp.registerPlayer(
    "{uniquePlayerId}", 
    "{playerEmail}",
    "{playerMobile}",
    playerAttributes, 
    this, 
    this.getIntent(), 
    new Callback<PlayerRegisterResponse>() {
        @Override
        public void onSuccess(PlayerRegisterResponse playerRegisterResponse) {
            // TODO Handle on success result.
        }
    
        @Override
        public void onError(Throwable e) {
            // TODO Handle on failure result.
        }
});

Last updated