After installing the SDK, the next step is to initialize Gameball when your app launches.
This prepares the SDK to track events, register customers, and display widgets.
You should initialize Gameball as early as possible—typically in your AppDelegate, SceneDelegate, or SwiftUI App initializer.
1. Basic Initialization
🔒
Secure API Access: To benefit from v4.1 secure API endpoints, pass the sessionToken parameter during SDK initialization (required in upcoming SDK v4). This enables automatic routing to v4.1 secure endpoints. Learn more about v4.1 →
2. Configuration Parameters
Below are all supported fields of GameballConfig.
Your Gameball project API key from the dashboard.
Language code, e.g., “en” or “ar”.
Platform identifier. Defaults to "ios".
Shop identifier used in multi-shop setups.
Optional Session Token for secure authentication, enables automatic routing to Gameball v4.1 APIs. Required in upcoming SDK v4.
3. Validation Rules
GameballConfig enforces:
- apiKey must not be empty
- lang must not be empty
If any required parameter is missing, initialization will fail silently and SDK methods will not be available.
4. Configuration Examples
Basic Setup
Multi-Shop Configuration
Using Session Token (v4.1 Routing)
Custom API Prefix
5. Environment-Specific Configuration (Recommended)
Use your test key during development and live key in production.
6. Loading Configuration From a File (Optional)
If you prefer not to embed keys directly in code, you can store them in a .plist.
GameballConfig.plist
Load configuration in code:
Initialize the SDK as early as possible so tracking and profile features are ready immediately.
Always use test keys in development.
Never commit live API keys to version control.