Initialization

Import our SDK into the created pod, using CocoaPods, to setup the Gameball Widget in the best way for your use-case.

In order to use Gameball you must configure a GameballApp.

  • Import our pod to your viewController

import GameBallSDK
  • Create a global GameballApp variable in your viewController to access anywhere within your viewController

var gameballApp: GameballApp?
  • In your viewControlller viewDidLoad() method add this

//Change the APIKEY , Language , player ID based on your references
let gameball = GameballApp.init(APIKey: "xxxxxxxxxxxxxxx", lang: "en")
self.gameballApp = gameball

The below is description of Initialization params

Parameters

Required

Description

Type

APIKey

Required

Your Gameball unique client API Key

How to get your Gameball account API Key

String

lang

Optional

Your platform language preference to view Gameball Widget with. If not provided, Gameball app will appear in English.

String:

ar

de

en

es

fr

pl

pt

User Registration

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

let playerAttributes: [String : Any] = [
"displayName": "Martin spiderman",
"email": "example@example.com",
"gender": "m",
"mobileNumber": "01280448448",
"dateOfBirth": "2019-08-18T10:11:34.478Z",
"joinDate": "2019-08-18T10:11:34.478Z",
"custom" : [
"customAttribute1": "string",
"customAttribute2": 0,
"customAttribute3": "2019-09-19T21:06:29.158Z",
"customAttribute4": true //boolean values (true or false)
]
]
self.gameballApp?.registerPlayer(withPlayerUniqueId:
playerUniqueId, withPlayerTypeId: playerTypeId,
withPlayerAttributes: playerAttributes, withDeviceToken: deviceToken)

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.

Object

deviceToken

Optional

Mobile device token used for push notifications

String

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

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.