Initialize Gameball Player Profile

Show your players's profile including all details and progress on your iOS 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 iOS 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.
Gameball’s views are accessible through the code below. You just need to use it on any button action.
//Change the APIKEY , Language , player ID , player attributes based on your references
let playerAttributes: [String : Any] = [
"displayName": "John Smith",
"email": "[email protected]"
withPlayerUniqueId: <YOUR_PLAYER_UNIQUE_ID>,
withPlayerAttributes: playerAttributes,
withDeviceToken: <Use_FirebaseSDK_To_generate_FCMToken>, //Check bellow
withLang: "en") { (GBVC, error) in
guard let gameBallVC = GBVC else {return}
self.present(gameBallVC, animated: true, completion: nil)
To generate Device Token (FCM Token) you can use Firebase latest SDK you can put this code in AppDelegate or your ViewController to get the token and once you get the token you can call the above method to register and Launch Gameball
// Based on latest Firebase documentation you can generate token by
Messaging.messaging().token { token, error in
if let error = error {
print("Error fetching FCM registration token: \(error)")
} else if let token = token {
print("FCM registration token: \(token)")
// you can save the token anyware then use it while launching Gameball
Once the APIKey and playerUniqueId have been registered, Gameball views can be made visible to the player.
The below is description of Initialization params
Client API key
Unique identifier for the player in your database.
Could be database ID, random string, email or anything that uniquely identifies the player.
Your platform language preference to view Gameball Widget with.
Note: The language provided should be as per configured languages in your account.
Example: "en", "fr".
Everytime the Gameball View 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.