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.

To initialize Gameball player using the SDK in your application class, use the init method which takes 4 parameters:
Parameter | Type | Required | Description |
APIKey | string | Yes | Client API key |
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. |
notificationIconId | string | Yes | The ID of the icon you want to use for notification |
lang | string | No | Your platform language preference to view Gameball Widget with. Note: 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" . |
GameBallApp.getInstance(getApplicationContext()).init("{{Your_API_Key}}",
playerUniqueId, R.mipmap.ic_launcher, lang);
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.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.registerPlayer(PlayerUniqueId, PlayerTypeId, PlayerAttributes, CallBack)
Parameter | | Required | Description |
PlayerUniqueId | string | Required | Unique identifier for the player in your database. Could be database ID, random string, email or anything that uniquely identifies the player. |
PlayerTypeId | string | Optional | leave empty |
PlayerAttributes | object | Optional | PlayerAttributes is a builder class with set of properties that you want to set for the player. |
CallBack | function | Optional | callBack is used for providing the developer with the response status |
PlayerAttributes Object
PlayerAttributes is a builder class and can be used as
= > new PlayerAttributes.Builder().withDisplayName(“Jack”).build();
The previous example will return an object of PlayerAttributes with DisplayName “Jack”
To add custom attributes:
- Build PlayerAttributes instance first
- Use addCustomAttribute on the instance you have just created
- addCustomAttribute(String Key, String value)
- Key = one of the defined keys in your dashboard
- Value is a string format of your specified type of the corresponding key in your dashboard
To show the Gameball player profile that contains the user details, user challenges, and the leaderboard use showProfile SDK method.
showProfile(AppCompatActivity activity, @Nullable String playerUniqueId)
It takes as a parameter the activity of the fragment you are calling the method from, it will show an activity of Gameball interface.
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 languageExample:
"en"
, "fr"
.
Last modified 22d ago