Skip to main content

Open the Gameball Profile Widget

Use the Gameball profile widget to show customers their points, rewards, tiers, leaderboards, and history inside your Android app.
Before showing the profile widget, make sure the SDK is initialized and the customer has been registered using Initialize SDK and Initialize Customer Profile.

Basic Usage

Create a ShowProfileRequest and call showProfile from GameballApp.
val profileRequest = ShowProfileRequest.builder()
    .customerId("customer-123")
    .build()

GameballApp.getInstance(context).showProfile(
    profileRequest,
    object : Callback<Boolean> {
        override fun onSuccess(success: Boolean) {
            // Profile widget displayed successfully
        }

        override fun onError(error: Throwable) {
            // Handle error
        }
    }
)

// With session token override
GameballApp.getInstance(context).showProfile(
    profileRequest,
    callback,
    sessionToken = "custom-token"
)

Request Parameters

customerId
string
required
Unique identifier for the customer whose profile will be displayed.
openDetail
string
Specific section to open inside the widget (for example, "details_earn", "details_redeem"). If not set, the main profile view opens by default.
hideNavigation
boolean
Hides the widget navigation bar when set to true. Defaults to false.
showCloseButton
boolean
Shows a close button within the widget when set to true. Defaults to false.
closeButtonColor
string
Hex color string for the close button (for example, "#FF5733").
Only applies when showCloseButton is true.
widgetUrlPrefix
string
Custom widget URL prefix for advanced widget customization.

Validation Rules

ShowProfileRequest requires:
  • customerId cannot be empty

Advanced Configuration

Open a Specific Section

Use openDetail to deep link into a specific section (for example, “earn” details):
val profileRequest = ShowProfileRequest.builder()
    .customerId("customer-123")
    .openDetail("details_earn")  // Open the earn points section
    .build()

Custom Close Button

Show a custom-colored close button on the widget:
val profileRequest = ShowProfileRequest.builder()
    .customerId("customer-123")
    .showCloseButton(true)
    .closeButtonColor("#FF5733")
    .build()

Hide Navigation

Hide the widget’s internal navigation controls:
val profileRequest = ShowProfileRequest.builder()
    .customerId("customer-123")
    .hideNavigation(true)
    .build()
Handle links clicked from within the widget (for example, to open custom screens or deep links):
val profileRequest = ShowProfileRequest.builder()
    .customerId("customer-123")
    .capturedLinkCallback(object : Callback<String> {
        override fun onSuccess(url: String) {
            // Handle captured URL
            Log.d("GameballWidget", "Link clicked: $url")
            // Navigate to a custom screen or handle deep link
        }

        override fun onError(error: Throwable) {
            // Handle error
        }
    })
    .build()

Implementation Examples

Show Profile from a Button

Display the profile widget when the user taps a button.
class MainActivity : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)

      findViewById<Button>(R.id.btnShowProfile).setOnClickListener {
          showCustomerProfile()
      }
  }

  private fun showCustomerProfile() {
      val profileRequest = ShowProfileRequest.builder()
          .customerId("customer-123")
          .build()

      GameballApp.getInstance(this).showProfile(
          profileRequest,
          object : Callback<Boolean> {
              override fun onSuccess(success: Boolean) {
                  // Profile displayed
              }

              override fun onError(error: Throwable) {
                  Toast.makeText(
                      this@MainActivity,
                      "Error: ${error.message}",
                      Toast.LENGTH_SHORT
                  ).show()
              }
          }
      )
  }
}

Bottom Navigation Integration

Open the profile widget when the user taps a “Rewards” tab:
bottomNavigationView.setOnItemSelectedListener { item ->
    when (item.itemId) {
        R.id.nav_rewards -> {
            val profileRequest = ShowProfileRequest.builder()
                .customerId(getCurrentCustomerId())
                .build()

            GameballApp.getInstance(this).showProfile(profileRequest, callback)
            true
        }
        else -> false
    }
}

What the Widget Shows

The profile widget typically includes:

Customer Info

Display name, points balance, and tier level.

Reward Campaigns

Available rewards, missions, and how to earn them.

Leaderboard

Customer ranking and top performers.

Transaction History

History of points earned and redeemed.
The content, layout, and branding of the profile widget can be configured from your Gameball dashboard.

Best Practices

1

Make Access Easy

Place entry points to the profile widget in prominent locations (for example, main navigation, profile screen, or a dedicated Rewards tab).
2

Use Badges

Show badges or indicators when a customer has new rewards or achievements to view.
3

Use Deep Linking

Use the openDetail parameter to open specific sections based on context (for example, after checkout, open the rewards section).
4

Handle Errors Gracefully

Always implement the error callback to show friendly messages if the widget fails to load (for example, due to network issues).
Consider showing the profile widget immediately after a customer earns points or unlocks a reward to reinforce engagement.