Add Ad Click Event Callback for Rewarded Video Ads to capture if the user click on the rewarded video ads.
Currently, the @capacitor-community/admob plugin does not provide an event callback for when a user clicks on a rewarded video ad. This feature would be helpful for tracking ad engagement and improving analytics.
when we need to track ad clicks for rewarded video ads to analyze user interaction. Some use cases involve rewarding users based on engagement, tracking analytics, or logging events for optimization. Native AdMob SDKs provide ad click events, but this functionality is missing in the Capacitor plugin.
Any update on the above issue?
I have found a solution for this. I added a custom ad click to the video ad and successfully retrieved the listener callback in JavaScript.
Java code
override fun onAdClicked() {
notifyListenersFunction.accept(RewardAdPluginEvents.RewardedAdClicked, JSObject())
}
Swift code
func adDidRecordClick(_ ad: GADFullScreenPresentingAd) {
NSLog("RewardFullScreenDelegate Ad did clicked")
plugin?.notifyListeners(RewardAdPluginEvents.RewardedAdClicked.rawValue, data: [:])
}
Javascript listener
addListener(eventName: RewardAdPluginEvents.RewardedAdClicked, listenerFunc: () => void,): Promise<PluginListenerHandle>;
I have found a solution for this. I added a custom ad click to the video ad and successfully retrieved the listener callback in JavaScript.
Java code
override fun onAdClicked() {
notifyListenersFunction.accept(RewardAdPluginEvents.RewardedAdClicked, JSObject())
}
Swift code
func adDidRecordClick(_ ad: GADFullScreenPresentingAd) {
NSLog("RewardFullScreenDelegate Ad did clicked")
plugin?.notifyListeners(RewardAdPluginEvents.RewardedAdClicked.rawValue, data: [:])
}
Javascript listener
addListener(eventName: RewardAdPluginEvents.RewardedAdClicked, listenerFunc: () => void,): Promise<PluginListenerHandle>;
But here's the issue: When the user clicks on the rewarded video ad while it's running, the ad click is detected correctly. However, if the user clicks the ad after the rewarded video has completed (i.e., after the reward is granted), the ad click is not detected.
This behavior started after the recent modifications made in the code (as mentioned in the comment above). Could anyone help identify what might be causing this?