Initialization

Initialize Gameball SDK in your application class.

To initialize Gameball SDK in your application class, you have two different ways depending on your user status.

Guest Player

Use the init method which takes 2 parameters :

  1. The ApiKey provided by Gameball. Check How can you get your account integration details? to get your ApiKey

  2. The ID of the icon you want to use for notification

GameBallApp.getInstance(getApplicationContext()).init("<ApiKey>", R.mipmap.ic_launcher);

User Player

If your player is logged in or your application is not user based. Use the init method which takes the following parameters:

  1. The ApiKey provided by Gameball

  2. PlayerUniqueID which is a unique ID that identifies your user

  3. PlayerTypeID which identifies the type of the player. You can ignore this parameter if you have only one player types on your Gameball account. Check What is “Player Type article for more info.

  4. ID of the icon you want to use for notifications

Note: Providing the init method with a new PlayerUniqueId will automatically create a new player in Gameball

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.

GameBallApp.getInstance(getApplicationContext()).init(<ApiKey>, <PlayerUniqueID>, R.mipmap.ic_launcher);
GameBallApp.getInstance(getApplicationContext()).init(<ApiKey>", "<PlayerUniqueID>",<playerTypeID>, R.mipmap.ic_launcher);

User Registration

Register player method is used to create or update the player details at Gameball. Ideally it is called when your login network call is successful.

registerPlayer(PlayerUniqueId, PlayerTypeId, PlayerAttributes, CallBack)

Parameter

Required

Description

Type

PlayerUniqueId

Required

PlayerUniqueId is a unique ID for you user, for example UUID or Username. The PlayerUniqueId is to be provided by the client and must be unique for each user.

String

PlayerTypeId

Optional

Each player type has an ID

Integer

PlayerAttributes

Optional

PlayerAttributes is a builder class which is used to add or update your player info to Gameball. Player object is described in Object Reference section.

String

CallBack

Optional

callBack is used for providing the developer with the response status

Function

PlayerAttributes

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

Once the APIKey and PlayerUniqueId have been registered, Gameball views can be made visible to the user.

Update User Data

User data can be updated by using editPlayerAttributes functions. It can be used to change or add information about the player such as display name, gender, joining date, and so on.

editPlayerAttributes(PlayerAttributes playerAttributes, Callback callback)
  • It takes PlayerAttributes object which is a builder class as mentioned in registerPlayer method description

  • It takes a callback to provide you with the response