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 | Yes | Current activity instance holding the GameballApp which will be used in showing the Player's profile. |
| String | Yes | Unique identifier for the player in your database. Could be database ID, random string, email or anything that uniquely identifies the player. |
| String | No | |
| Boolean | No |
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 registerPlayer
method 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 |
| String | Yes | Unique identifier for the player in your database. Could be database ID, random string, email or anything that uniquely identifies the player. |
| String | No | Player's unique Email address. |
| String | No | Player's unique Mobile number. |
| object | No | PlayerAttributes is a builder class with set of properties that you want to set for the player. |
| Activity | Yes | Current activity instance holding the GameballApp which will be used in detecting the referal code from the dynamic link. |
| Intent | Yes | An intent instance that will be used in combination with the Activity to detect the referal code from the dynamic link. |
| 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.
Method | Parameter Name | Type |
---|---|---|
| displayName | string |
| firstName | string |
| lastName | string |
| string | |
| gender | string |
| mobileNumber | string |
| dateOfBirth | string |
| joinDate | string |
| preferredLanguage | string (ex: en, fr, ar) |
| (key, value) | (string, string) |
| (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
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
Last updated