Search code examples
swiftuitableviewreloaddataadmob-rewardedvideoad

Reloading Table View After Watching a Rewarded Video


Recently I've implemented the rewarded video feature in the code and it works well. Simply, when the user chooses the level from the table view and watches the rewarded video, it unlocks the level. But when the user closes the ad view, table view stays the same, not reloaded with the new information.

I tried some solution I found here but nothing worked.


Solution

  • You can set event notification on the reward video opening controller. Use these lines of code in viewDidLoad

    GADRewardBasedVideoAd.sharedInstance().delegate = self
    

    GADRewardBasedVideoAdDelegate notifies you of rewarded video lifecycle events. You are required to set the delegate prior to loading an ad. The most important event in this delegate is rewardBasedVideoAd:didRewardUserWithReward:, which is called when the user should be rewarded for watching a video. You may optionally implement other methods in this delegate.

    Then you need to implement this delegate

    func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd,
    didRewardUserWith reward: GADAdReward) {
        print("Reward received with currency: \(reward.type), amount \(reward.amount).")
    
     // RELOAD YOUR TABLE VIEW DATA HERE
    }
    

    For details you can see detail implementation here