gameball_sdk 1.0.2
gameball_sdk: ^1.0.2 copied to clipboard
Gameball Integration SDK allowing direct communication with multiple Gameball services like Customer creation, sending Events, and showing Gameball Profile
Gameball Flutter SDK #
Gameball Flutter SDK is a library that allows you to integrate the Gameball platform's features into your Flutter applications. It enables you to: #
- Register players and track their activities.
- Send personalized events to trigger Gameball campaigns.
- Display the Gameball user interface within your app.
Installation #
1 Add the Gameball Flutter SDK dependency to your pubspec.yaml file or the flutter add command directly:
YAML
dependencies:
gameball_sdk: ^latest
Bash
$ flutter pub add gameball_sdk
- Import the library in your Dart code:
Dart
import 'package:gameball_sdk/gameball_sdk.dart';
Usage #
- Initialization
- Create an instance of
GameballApp:
Dart
GameballApp gameballApp = GameballApp.getInstance();
- Initialize the Gameball SDK with your API key, language, platform, and shop information:
Dart
gameballApp.init("{api_key}", "{lang}", "{platform}", "{shop}");
- Firebase Initialization (for referral handling):
- Ensure Firebase is initialized in your app before using referral features:
Dart
import 'package:firebase_core/firebase_core.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
// ... rest of your app
}
- Player Registration:
- Register a player with their unique ID, email (optional), mobile number (optional), and custom attributes:
Dart
PlayerAttributes playerAttributes = PlayerAttributes(
displayName: "John Doe",
firstName: "John",
lastName: "Doe",
mobileNumber: "0123456789",
preferredLanguage: "en",
customAttributes: {
"{key}": "{value}",
},
);
gameballApp.registerPlayer(
"{playerUniqueId}",
"{playerEmail}",
"{playerMobile}",
playerAttributes,
(response, error) {
// Handle registration response
},
);
- Sending Events:
- Define an
Eventobject with the player's unique ID and event details:
Dart
Event eventBody = Event(
playerUniqueId: "{playerUniqueId}",
events: {
"{eventName}": {
"{prop1}": "{value1}",
},
},
);
gameballApp.sendEvent(eventBody, (success, error) {
// Handle event sending response
});
- Showing Gameball Profile:
- Display the Gameball user interface within your app using
showProfile:
Dart
gameballApp.showProfile(context, "{playerUniqueId}", "{openDetail}", "{hideNavigation}");
- Replace
contextwith the current build context. - Use placeholders for
playerUniqueId,openDetail(optional URL to open within the profile), andhideNavigation(optional boolean to hide navigation arrow). Note: Replace all instances of"{...}"placeholders with your actual values.
Additional Resources #
- For detailed API reference and comprehensive documentation, visit the official Gameball developer website: https://developer.gameball.co/
- Explore the Gameball platform and its features at the Gameball website: https://www.gameball.co/
- Feel free to contact Gameball support for any further assistance.