Referrals Module on React Native

Configure the referral module on your React native 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

For dynamic links you can use react-native firebase package and follow the steps of dynamic links initialization. To get the initial link that is used to start the app, use:

 let initialLink = await firebase.links().getInitialLink();

If there is a link, call the getReferralCode function and pass the URL as a parameter:

let referralCode = GameballSdk.getReferralCode(initialLink);

After this, call addReferral function:

GameballSdk.addReferral({
      "playerCode": referralCode,
      "playerUniqueId": playerId,
      "deviceToken": await AsyncStorage.getItem('push_token'),
      "osType": Platform.OS === 'ios' ? 'ios' : 'android',
      "playerAttributes": {
        "displayName": displayName,
        "email": email,
        "gender": gender,
        "mobileNumber": mobileNumber,
        "dateOfBirth": dateOfBirth,
        "joinDate": new Date(),
      }
    })).then(response => console.log(response))  // on success
    .catch(error => console.log(error)) // on error

Parameter

Required

Description

Type

playerCode

Required

referralCode extracted from the link

String

playerUniqueId

Required

player ID is a unique ID for you user. (eg. user email, UUID,.. etc.). The playerId is to be provided by the client and must be unique for each user.

String

playerTypeId

Optional

Each player type has an ID

Integer

playerAttributes

Optional

PlayerAttributes is a builder class which is used to add or update your player info to Gameball. Player object is described in Object Reference section.

Object

deviceToken

Optional

Mobile device token used for push notifications

String

osType

Optional

Operating system of the device running the application

String

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

Last updated