Getting Started
Install the Gameball React Native SDK into your app
The Gameball Android and iOS package, 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 react native SDK package to your app
    Install package using npm
1
npm install --save react-native-gameball
Copied!
    Install prerequisite package using npm
1
npm install axios react-native-modal react-native-push-notification-popup
Copied!
Axios, react-native-modal and react-native-push-notification-popup packages are required to use gameball package.

iOS Installation

    Install pod package using pod install
1
cd ios — {navigate to the IOS directory in the project}
2
pod install
3
cd ..
Copied!

Installation Issues

"rnc webview was not found in the UI manager iOS sol"
    1.
    check that react-native-webview if installed and in package.json. If not, install it through
1
npm install --save react-native-webview
2
cd ios
3
pod install
Copied!
If the issue persists, run the following line in the project directory
1
react-native link react-native-webview
Copied!

Initialization

In order to use Gameball SDK, apply the below step to the main JS file (index or app).
Import Gameball Widget
1
import {GameballWidget} from ‘react-native-gameball’;
Copied!
Initialize Gameball Widget
1
GameballWidget.init(gameball_apiKey, gameball_lang, gameball_shop)
Copied!
Parameter
Type
Required
Description
gameball_apiKey
Yes
string
Client API key
gameball_lang
No
string
Your platform language preference to view Gameball Widget with.
Note: The language provided should be as per configured languages in your account. If not provided the Gameball profile widget will be shown with your account default language
Example: "en", "fr".
gameball_shop
No
string
Shopify store name with myshopify.com domain. Used if your app is a mobile app for a shopify store connected to Gameball

Register Player

Register player method is used to create or update players at Gameball. It is called when your login network call is successful.
First, import Gameball SDK as follows:
1
import {GameballSdk} from 'react-native-gameball';
Copied!
then
1
GameballSdk.registerUser({
2
"playerUniqueId": playerId,
3
“playerTypeId”: playerTypeId,
4
"deviceToken": playerDeviceToken,
5
"osType": Platform.OS === 'ios' ? 'ios' : 'android',
6
"playerAttributes": {
7
"displayName": “Alex”,
8
"email":[email protected].com",
9
"gender": “m”,
10
"mobileNumber":01099999999,
11
"dateOfBirth": "2019-08-18T10:11:34.478Z",
12
"joinDate":2019-08-18T10:11:34.478Z”
13
}
14
}).then(response => console.log(response)) // on success
15
.catch(error => console.log(error)) // on error
Copied!
Once the APIKey and playerUniqueId have been registered, Gameball views can be made visible to the user.
Param
Required
Description
Type
playerUniqueId
Required
PlayerUniqueId is a unique ID for you user, for example UUID or username. The PlayerUniqueId 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 you will use 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
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 1mo ago