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 4 parameters (2 of the are optional):

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

  2. The playerUniqueId which is your user's gameball Id (optional)

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

  4. the language which is a 2 character string representing the desired language of the widget (optional). Ps. in case you didnt send this value the widget will have the system's default language

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

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. 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.

  3. 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);

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)

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

Last updated