I am using Swift 3.0 and Xcode 8 Beta 6. My app is not released on the AppStore yet.
I think I am missing something here but I don't know what. I used iAds before with other apps without any problem. But this is the first time Im trying Rewarding Videos and AdMob.
I followed your tutorial and wrote this code in my AppDelegate.swift:
FIRApp.configure()
GADMobileAds.configure(withApplicationID: "my_app_id_created_on_admob")
let request = GADRequest()
GADRewardBasedVideoAd.sharedInstance().load(request, withAdUnitID: "my_add_unit_created_on_admob")
Then I had this in a UIViewController I am pushing when clicking on a button.
I want this VC to present the rewarding ads when it's loaded. So I also set it the AdMob delegate:
override func viewDidLoad() {
super.viewDidLoad()
GADRewardBasedVideoAd.sharedInstance().delegate = self
}
I declared this VC following GADRewardBasedVideoAdDelegate as well and add all those protocol implementations at the end of the VC:
func rewardBasedVideoAdDidOpen(_ rewardBasedVideoAd: GADRewardBasedVideoAd!) {
print("rewardBasedVideoAdDidOpen")
}
func rewardBasedVideoAdDidClose(_ rewardBasedVideoAd: GADRewardBasedVideoAd!) {
print("rewardBasedVideoAdDidClose")
GADRewardBasedVideoAd.sharedInstance().load(GADRequest(), withAdUnitID: "my_add_unit_created_on_admob")
}
func rewardBasedVideoAdDidReceive(_ rewardBasedVideoAd: GADRewardBasedVideoAd!) {
print("rewardBasedVideoAdDidReceive")
}
func rewardBasedVideoAdDidStartPlaying(_ rewardBasedVideoAd: GADRewardBasedVideoAd!) {
print("rewardBasedVideoAdDidStartPlaying")
}
func rewardBasedVideoAdWillLeaveApplication(_ rewardBasedVideoAd: GADRewardBasedVideoAd!) {
print("rewardBasedVideoAdWillLeaveApplication")
}
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd!, didRewardUserWith reward: GADAdReward!) {
print("Should reward user with \(reward.amount) \(reward.type)")
}
func rewardBasedVideoAd(_ rewardBasedVideoAd: GADRewardBasedVideoAd!, didFailToLoadWithError error: Error!) {
print("didFailToLoadWithError")
GADRewardBasedVideoAd.sharedInstance().load(GADRequest(), withAdUnitID: "my_add_unit_created_on_admob")
}
2 questions from there:
Why did some videos where showing fine even if I didn't implemented any other mediation network yet on AdMob dashboard?
Why didnt the didRewardUserWith was called after I watched the videos shown on my development device?
I was thinking that maybe it was normal, and this didRewardUserWith function would only be triggered by other mediation network advertisements. So I implemented 3 other ones (AdColony, Chartboost and AppLovin) to check if that was the reason... But then it is just HELL: no documentation up to date for those one, "adaptaters" needed but mostly not compatible with the latest AdMob framework, bridges needed from Obj-C to Swift without anyone telling it...
Other thing: since this morning, I don't really know why, my GADRewardBasedVideoAd.sharedInstance() didn't succeed to load an ads video anymore...
Any help here would be veeeeeery appreciated... I'm running out of hope :(