Gift and Reward

 

This KTplay Gift and Reward feature allow developer to send reward instruction to targeted device (or player) from KTplay developer portal, once a reward event is received in SDK, it will call back to the game client, and the actual reward logic will be executed in the callback function, the Reward Handler.

Reward Handler

The Reward Handler is the callback function for handling Reward event and responsible for handle reward execution.

The game can have the reward logic on the game client side, or call their game server to handle the reward, and in that case, Game server can utilize KTPlay Open API to verify of the reward is valid.

Please Refer to Open API documentation for details.

KTPlay.setOnDispatchRewardsListener(new OnDispatchRewardsListener() {
    @Override
    public void onDispatchRewards(Reward reward) {
            
            Game.reportRewardEvent(reward.messageId,
                                        reward.gameUserId,
                                        reward.ktUserId);
         
        for(KTRewardItem item : reward.items){
             Game.applyReward(item);     
        }
    }
});


 KTDidDispatchRewardsBlock rewardBlock = (KTReward * reward){
     
    [Game reportRewardEvent:reward.messageId 
                     gameUserId:reward.gameUserId 
                        ktUserId:reward.ktUserId];
                        
                    
    for (KTRewardItem *item in reward.items) {
         [Game applyReward:item];   
        }
    }

[KTPlay setDidDispatchRewardsBlock: rewardBlock]

void dispatchRewards (KTRewardC * reward){
    Game::reportRewardEvent(reward->messageId,
                                    reward->gameUserId,
                                    reward->ktUserId);

    for ( int i = 0; i < reward->length; i ++) {
            KTRewardItemC *item = &reward->items[i];
            Game::applyReward(item);
    }
}

KTPlayC::setDidDispatchRewardsCallback( dispatchRewards );

KTPlay.SetDidDispatchRewardsDelegate ((KTReward * reward) => {
   
    Game.reportRewardEvent(reward.messageId,
                                    reward.gameUserId,
                                    reward.ktUserId);
    
    for (int i = 0; i < reward.items.Count; i++) {
        KTPlayRewardsItem item = (KTPlayRewardsItem)reward.item[i];
         Game.applyReward(item);   
    }
});
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.