Gameball Developers Guide
v3.0
v3.0
  • Introduction
  • What's New in V3.0
  • Installing Gameball
    • Web
      • Show Gameball Customer Widget
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Go-Live Checklist
    • iOS
      • Getting Started
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
    • Android
      • Getting Started
      • Initialize Gameball SDK
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
    • React Native
      • Getting Started
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
      • Migration from v1 to v2
    • Flutter
      • Getting Started
      • Initialize Gameball SDK
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Referrals
      • Go-Live Checklist
    • Generic Mobile App
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
    • Retail & Modern POS
      • Initialize Gameball Customer Profile
      • Track Orders & Cashback Reward
      • Track Refunds
      • Enable Redemption
        • Prepare POS for Redemption
        • Using Virtual ID
          • Using Virtual Card
  • REST API
    • Overview
      • Server-Side SDKs
    • Authentication
    • API Reference
      • Customer
      • Event
      • Transactions
      • Order
      • Coupons
      • Leaderboard 👑
      • Notifications 👑
      • Configurations 👑
      • Batches 👑
        • Batch Operations Data
      • OTP
      • Partner 🤝
        • Client 🤝
        • Redemption Rule 🤝
        • Cashback Rule 🤝
    • Webhooks
      • Notifications Webhook
      • Customer Profile Webhook
    • Errors
    • Object Reference
  • Tutorials
    • Build Custom UI Elements 👑
      • Display Reward Campaign Progress
      • Show VIP Tiers
      • Show Customer Points Balance
      • Build Leaderboards
      • Show Notifications Inbox
      • Adapt UI to Configurations
      • Advanced UI Techniques
        • Increase Sales with Cashback UI Elements
        • Derive Engagement with Rewards Campaigns UI Elements
    • Tracking Customer Events
    • Build your Own Notification System
    • Checkout Integration Example
    • Redemption Integration Options
      • Redeem with coupon system
        • Integrate your coupon system
          • Example using e-commerce platform(WooCommerce)
          • Example using a custom coupon system
        • Build couponing experience
          • Using Gameball widget
          • Build custom experience
            • Showing customers available points
            • Allowing customers to create coupons
            • Apply the discount code to your cart
        • Coupon integration reference
      • Redeem with direct debt
        • Get customers points balance
        • Redeem customer points
  • Third Party Integrations
    • Segment Integration
Powered by GitBook
On this page
  • Register Customer
  • Show the Widget
  1. Installing Gameball
  2. iOS

Initialize Gameball Customer Profile

Show your customers' profile including all details and progress on your iOS app.

PreviousGetting StartedNextTrack Customer Events

Last updated 1 year ago

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 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’s 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: "UNIQUE_PLAYER_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

Parameter

Type

Required

Description

playerUniqueId

string

Yes

Unique identifier for the customer in your database. Could be database ID, random string, email or anything that uniquely identifies the customer.

deviceToken

string

No

Firebase token obtained from Firebase SDK to avail Gameball to send notifications to the customer.

playerAttributes

dictionary

No

Any custom parameters you want to attach to the customer.

completion

Completion block

Yes

Returns either gameball player ID or error in registration.

Choose an Unchangeable Player Unique ID

Gameball customer gets created using theplayerUniqueId. 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, 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 customer 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.

Parameter
Type
Required
Description

playerUniqueId

String

Required

Unique identifier for the customer in your database. Could be database ID, random string, email or anything that uniquely identifies the customer.

String

Optional

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

hideNavigation

Boolean

Optional

Set to true to stop widget navigation otherwise leave as null

Everytime 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 avialable to the UI by using server side

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

openDetail
here
Create\Update Customer API