v4.0 (Beta)

Initialize Gameball Customer Profile

Show your customer'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 use the Configurations API 👑. The other option as this section elaborates, is through using our iOS SDK.

Using the SDK, you can open the Gameball customer 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 customer profile, your customer is presented with a home screen. This is configurable inside Gameball to change how it looks and what’s presented.

From there, your customer can check his progress across different Gameball programs as per your configurations.

Gameball views are accessible through the code below. You just need to use it on any button action.

Register Customer

The Register Player method is used to create or update customer accounts at Gameball. This API call should be made when the customer successfully logs in or whenever there are updates to the customer's account information.

// After completion block is called from init the SDK, you can register customer

self.gameball?.registerPlayer(
    playerUniqueId: "CUST_ID", // The only required field
    deviceToken: "firebase_token",
    playerAttributes: [
        "custom_attribute": "custom_value",
        "country": "Egypt"
    ],
    completion: { (playerId, error) in // Completion block after registeration is complete
    // You either get gameball playerId or error
})

The below is description of register player parameters

playerUniqueId string Required

Unique identifier for the customer that you can reference across the customer’s whole lifetime. Could be a database ID, random string, email or anything that uniquely identifies the customer.


deviceToken string Required

The Firebase Cloud Messaging (FCM) token associated with the customer’s mobile device. Required for enabling push notifications to be sent to the customer.


playerAttributes Object Optional

Additional customer-specific attributes. Includes attributes such as the customer’s name, contact details, and purchase history.

playerAttributes Object

displayName string Optional

The display name of the player.


firstName string Optional

The first name of the player.


lastName string Optional

The last name of the player.


email string Optional

The email address of the player.


gender string Optional

The gender of the player. Use "M" for male, "F" for female, or other identifiers as needed.


dateOfBirth string Optional

The player's date of birth in the format YYYY-MM-DD.


joinDate string Optional

The date the player joined, in the format YYYY-MM-DD.


custom Object Optional

Custom attributes related to the player, defined by specific key-value pairs.


completion string Optional

Completion block that gets called when the initialization of the SDK is completed

Every time the Gameball View is initialized with a new PlayerUniqueId , the customer profile is created or updated at Gameball side. You may consider enriching your Gameball's customer profile with attributes that are not available to the UI by using server side Create\Update Customer 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 customer, you risk losing all original data for that customer and hence losing their points and rewards on Gameball. Accordingly, it is NOT recommended to use the email address or the mobile number as the unique ID as both can be changed by the user at anytime.

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 customer. So ideally, registerPlayer is called after the completion block of the SDK initalization.

Show the Widget

To show the Gameball customer profile that contains the customer details, customer reward campaigns, and the leaderboard use the showProfile SDK function.

@IBAction func didTapLaunch(_ sender: UIButton) {
    gameball?.showProfile(
        playerUniqueId: "UNIQUE_PLAYER_ID",
        openDetail: "custom_detail",
        hideNavigation: false,
        completion: { viewController, errorMessage in
            guard let gameBallVC = viewController else {return}
            gameBallVC.modalPresentationStyle = .fullScreen
            self.present(gameBallVC, animated: true, completion: nil)
        }
    )
}

Upon customer action, you can use showProfile function to show the widget. The completion block tells you that the viewController is ready and you can present it the way you want, for example by default if you don't explicitly specify modalPresentationStyle, it'll appear as modal. If you want it full screen, you can specify it like the above example.

playerUniqueId string Required

Unique identifier for the customer that you can reference across the customer’s whole lifetime. Could be a database ID, random string, email or anything that uniquely identifies the customer.


openDetail string Optional

Specify if you want the widget to open on a specific view. Possible values are:

  • details_referral

  • details_history

  • details_coupon

  • details_redeem

  • details_earn

  • details_reward_campaign

  • details_notification

  • details_wheels_list

  • details_wheel

  • details_family_members

  • details_family_invite


hideNavigation Boolean Optional

Set to true to stop widget navigation otherwise leave as null

You may also check the sample project here to view full implementation.

Last updated