Referrals Module on iOS

Configure the referral module on your iOS app using Firebase. This module allow users or players to refer others with a referral link and gain points.

Configure Gameball With Your Firebase

Before you start, you must configure your Firebase on your Gameball account. Follow the steps in Configure your Firebase account on Gameball for mobile friends referral links article in our Help Center to configure your Firebase account on Gameball.

Integration Details

Below are FireBase dynamic links configuration details.

  • Import FireBase in AppDelegate File

import Firebase
  • Copy this code in you AppDelegate

func handleIncommingDynamicLink(_ dynamicLink: DynamicLink){
        guard let url  = dynamicLink.url else {
        self.gameballApp?.recievedDynamicLink(url: url)
    func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        if let incommingURL = userActivity.webpageURL {
            let linkHandled = DynamicLinks.dynamicLinks().handleUniversalLink(incommingURL) { (dynamicLink, error) in
                guard error == nil else {
                if let dynamicLink = dynamicLink {
            return linkHandled
        return false
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        if let dynamicLink = DynamicLinks.dynamicLinks().dynamicLink(fromCustomSchemeURL: url){
            return true
        } else {
            return false

Referral Methods

If you need to use a referral method to sign up a new player using a referral link, call the function below to use the referral module. Best use case is in the success of the registration API of your app just call this method

Don’t call the registerPlayer, this method will register the new playerUniqueId

    let playerAttributes: [String : Any] = [
        "displayName": "Martin spiderman",
        "email": "",
        "gender": "m",
        "mobileNumber": "01280448448",
        "dateOfBirth": "2019-08-18T10:11:34.478Z",
        "joinDate": "2019-08-18T10:11:34.478Z"
    self.gameballApp?.friendReferral(playerUniqueId:"Spiderman5" , playerAttributes: playerAttributes, completion: { result in
print(result)} )

The playerAttributes is optional, so if you haven't created it yet then call the method like this with only the new playerUniqueId.

    self.gameballApp?.friendReferral(playerUniqueId:“Spiderman5”, completion: { result in print(result)
    } )

Now, referral links will be generated successfully for your players!

Last updated