Free to Play support
Provide available rewards at runtime
availableRewards
availableRewardsHandle reward claims
claimReward
claimRewardLink to reward history
viewRewards
viewRewardsLucraClient().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
