Getting Started
Install the Gameball iOS SDK into your app
The Gameball SDK for iOS enables you to use the show Gameball player profile in your app, track app player events, integrate referrals and display Gameball's in-app push notifications.

Installation

Follow the below steps to start installing the iOS SDK to your app
1. Add Cocoapods to Your Project
If your project is using CocoaPods, skip to the next part of this article, Add Gameball Pod.
    Open the terminal window
    Navigate to the root folder of your Xcode project
    Run the following command in terminal
1
$ pod init
Copied!
    Close Xcode if open then open your project’s newly created .xcworkspace
    Your project is now using CocoaPods to install dependencies
2. Add Gameball Pod
    Add the code below in your Podfile which was created by CocoaPods
1
target 'YourAppName' do
2
use_frameworks!
3
pod 'GameBallSDK',
4
End
Copied!
    Navigate to your project’s root folder in a terminal window
    Run the command below in terminal
1
$ pod install
Copied!
    Gameball will install several Pods that it has as dependencies.
When the Pod command finishes execution, you will have Gameball installed and ready to use.

Initialization

Import the 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
1
import GameBallSDK
Copied!
    Create a global GameballApp variable in your viewController to access anywhere within your viewController
1
let gameball = GameballApp()
Copied!

User Registration

You should register your players with Gameball. This can be done using registerPlayermethod which can be used to create or update the player details at Gameball. Ideally, it is called when your login or register network call is successful.
Register player method is used to create or update the player at Gameball. Ideally its called when your login network call is successful.
registerPlayer(PlayerUniqueId, PlayerTypeId, PlayerAttributes, deviceToken)
1
let playerAttributes: [String : Any] = [
2
"displayName": "Martin spiderman",
3
"email": "[email protected]"
4
]
5
6
self.gameballApp?.registerPlayer(withPlayerUniqueId:
7
playerUniqueId, withPlayerTypeId: playerTypeId,
8
withPlayerAttributes: playerAttributes, withDeviceToken: deviceToken)
Copied!
​
Parameter
​
Required
Description
PlayerUniqueId
string
Required
Unique identifier for the player in your database.
Could be database ID, random string, email or anything that uniquely identifies the player.
PlayerTypeId
string
Optional
leave empty
PlayerAttributes
object
Optional
An object with set of properties that you want to set for the player.
deviceToken
function
Optional
Mobile device token used for push notifications
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 modified 2mo ago