Free to Play Mobile Integration
Android and iOS Implementation Guide for FTP support
Lucra Reward Provider
As mentioned in the cover document, the front end transaction is fairly straightforward. The LucraSDK expects the following:
A way to fetch available
LucraRewards for the active clientThis can be an asynchronous action we'll wait to complete before showing the user what options are available
If no rewards are provided, the user will not be able to Create matchups.
A way to claim a given
LucraRewardwhen the matchup is ready to be claimedThis callback can only be called when the matchup has completed, it's the way for the tenant to navigate the user to the reward details.
The reward in the callback is the same
LucraRewardprovided to the client during creation.NOTE: There are no requirements for accepting a matchup with a given reward, meaning, a user will be able to accept a matchup with a reward that is not currently available to them.
Android LucraRewardProvider
Top level interface definition
interface LucraRewardProvider {
/**
* Return a list of available [Reward]s for the current user (asynchronous)
*/
suspend fun availableRewards(): List<LucraReward>
/**
* When a contest is won, the user can be linked back to the claim details on the client side.
*/
fun claimReward(reward: LucraReward)
}Example implementation
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
// TODO hide Lucra experience flows and navigate to reward details
}
})iOS LucraRewardProvider
Top level protocol definition
public protocol LucraRewardProvider: AnyObject {
/// Allows asynchronous provisioning of a set of rewards to be made available to users
/// - Returns: [LucraReward]
func availableRewards() async -> [LucraReward]
/// Provides custom logic for claiming a specified reward upon completion of a matchup. This can be handled within the app or by redirecting the user to a web page, for example.
/// - Parameters:
/// - reward: The reward to be redeemed
func claimReward(reward: LucraReward)
}Example Implementation
extension ClientRewardProvider: LucraRewardProvider {
func availableRewards() async -> [LucraReward] {
return [LucraReward(rewardId: "LucraInternalCompetition",
title: "Lucra Competition",
descriptor: "$2 Gift Card of Your Choice",
iconUrl: "https://lucrasports.com/images/about/images/energy-icon.svg",
bannerIconUrl: "https://i.imgur.com/AGEQN.jpeg",
disclaimer: "Just have fun!",
metadata: nil)]
}
func claimReward(reward: LucraReward) {
// TODO close Lucra flows and navigate user to reward details
navigateToRewardView(reward: reward)
}
}
lucraClient.registerRewardProvider(clientRewardProvider)Last updated