Free to Play support

In order to support promotional/reward based payouts for Sports and Games Matchups, a LucraRewardProvider instance must be provided to the LucraClient.

Provide available rewards at runtime

availableRewards

This callback expects a list of available rewards to show to the current user upon creating and accepting Sports contests. This is a suspendable function allowing clients to hit an API or other I/O service to fetch the available rewards for the logged in user.

Handle reward claims

claimReward

When the contest is completed, and the user has won. We allow the user to "claim reward" as a result of winning.

viewRewards

This is a callback invoked in the profile, where a "View My Rewards" button is shown to the user if the RewardProvider is available

The idea here is that the client can then navigate the user to the Reward details page of the client application.

LucraClient().setRewardProvider(object : LucraRewardProvider {
            override suspend fun availableRewards(): List<LucraReward> {
                return listOf(
                    LucraReward(
                        rewardId = "reward_001",
                        title = "Free Burger",
                        descriptor = "Get a free burger with any meal purchase",
                        iconUrl = "https://images.unsplash.com/photo-1555992336-03a23c46183e",
                        bannerIconUrl = "https://example.com/images/burger_banner.png",
                        disclaimer = "*Can only be redeemed once per week",
                        metadata = mapOf("custom_data" to "{\"type\":\"food\",\"expiry\":\"2024-12-31\"}",
                            "simple_data" to "primitive_type_to_string")
                    )
                )
            }

            override fun claimReward(reward: LucraReward) {
                // The idea is to "show" or "reveal" details of the client based Reward
                // In this case, we're simply dismissing the entire stack of Lucra Flows
                // NOTE: This will not work for all setups, it's important to keep track of all
                // instances of LucraFlows, whether they are DialogFragments or a specific Fragment.
                // You don't want to remove/dismiss fragments/dialogs that aren't related to Contest creation
                supportFragmentManager.fragments.filterIsInstance<DialogFragment>().forEach {
                    it.dismiss()
                }
                Toast.makeText(
                    this@MainActivitySdk,
                    "Claimed Reward: ${reward.title}",
                    Toast.LENGTH_LONG
                ).show()
            }
            
            override fun viewRewards() {
                // Navigate the user to client based rewards, allow them to view available and/or won Rewards
            }
        })

Last updated