Skip to main content

Initialize Customer (Register/Identify)

Register or update a customer whenever they log in or register in your app. This allows Gameball to attach events and rewards to the customer profile.
🔒
Secure API Access: To benefit from v4.1 secure API endpoints, pass the sessionToken parameter when calling methods (required in upcoming SDK v4). This enables automatic routing to v4.1 secure endpoints. Learn more about v4.1 →

Request Parameters

string
required
Unique identifier for the customer. This should never change for a given customer.
CustomerAttributes
Customer attributes built using CustomerAttributesBuilder.
string
Device token for push notifications (FCM or HMS).
PushProvider
Push notification provider: PushProvider.Firebase or PushProvider.Huawei.
string
Optional session token to override the global token for this specific request. Required in upcoming SDK v4.
In Flutter SDK, passing a sessionToken parameter updates the global token. Pass null to clear, or omit to use the current global token.

Validation Rules

InitializeCustomerRequest requires:
  • customerId cannot be null or empty
  • If deviceToken is provided, pushProvider must also be specified
  • If pushProvider is specified, deviceToken must also be provided

CustomerAttributesBuilder Methods

Build customer attributes using the builder pattern:
Choose an Unchangeable Customer IDThe customer ID should be a permanent identifier that will NEVER change. Avoid using email or phone number as the customer ID since these can be updated by users.

Show Customer Profile (Widget)

Display the Gameball customer profile widget to show rewards, campaigns, and leaderboards:
BuildContext
required
The Flutter BuildContext from your widget.
string
The customer’s unique identifier (omit for guest mode).
string
Specific detail to open in the profile.
bool
Hide navigation elements.
bool
Show close button (defaults to true).
string
Close button color in hex format (e.g., “#FF0000”).

Validation Rules

  • No required fields (guest mode supported). Provide customerId for authenticated profiles.
  • closeButtonColor must be in hex format (#RRGGBB) if provided

Full Example

Call initializeCustomer when the user logs in or registers to ensure their profile is up-to-date before showing the widget.

Next Steps