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

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

Last updated