swiftchartboost

How to give the player coins after he or she watches the reward video?


Im using Chartboost reward videos and Im having trouble figuring out how to give the player 100 coins after the video is done playing. Here is the code for the reward video. Right now its adding the 100 coins even if I x out of the reward video screen. How would I be able to give the coins after the player watches the video?

    func loadRewardedVideo() {

    let kChartboostAppID = "appID"
    let kChartboostAppSignature = "appSigniture"

    Chartboost.startWithAppId(kChartboostAppID, appSignature: kChartboostAppSignature, delegate: viewController)

    Chartboost.showRewardedVideo(CBLocationMainMenu)
    Chartboost.cacheRewardedVideo(CBLocationMainMenu)

    if Chartboost.hasRewardedVideo(CBLocationMainMenu) {
        Chartboost.showRewardedVideo(CBLocationMainMenu)

        coins += 200
        totalCoinLabel.text = String(coins)


    }

}

Solution

  • I have no personal experience with . However, based off reading their documentation, you need to set up a delegate:

    Chartboost.startWithAppId(
        "YOUR_CHARTBOOST_APP_ID",
        appSignature: "YOUR_CHARTBOOST_APP_SIGNATURE",
        delegate: self
    )
    

    And then, your delegate can implement this method to know when a user completely watched a rewarded video:

    func didCompleteRewardedVideo(location: CBLocation, withReward reward: Int)