Problem
The recent documentation shows that Ti.UI.iOS.AdView inherits the click/singletap/touchstart events but none of these events are fired when the iAd banner is clicked.
This makes it impossible to detect when the user clicks an ad and the ad covers the entire screen and in turn makes it impossible to use iAd with apps that must be paused when the ad covers the screen.
Test Case
var win = Ti.UI.createWindow({
orientationModes: [ Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT ],
layout: "absolute"
});
var iAdView = Ti.UI.iOS.createAdView({
bottom: "0px",
height: Ti.UI.SIZE,
width: Ti.UI.SIZE,
adSize: Ti.UI.iOS.AD_SIZE_PORTRAIT,
});
iAdView.addEventListener("load", function (e) {
alert("iad - loaded");
});
iAdView.addEventListener("error", function (e) {
alert("iad - error");
});
iAdView.addEventListener("action", function (e) {
//runs when ad is dismissed by the user
alert("iad - action");
});
iAdView.addEventListener("click", function (e) {
//never runs
alert("iad - click");
});
iAdView.addEventListener("singletap", function (e) {
//never runs
alert("iad - singletap");
});
iAdView.addEventListener("touchstart", function (e) {
//never runs
alert("iad - touchstart");
});
win.add(iAdView);
win.open();
Community Discussion
http://developer.appcelerator.com/question/148233/how-to-capture-iad-banner-click
Native ios ADBannerView does not support click,touch and tap events.
I don't think this is true. The ADBannerView calls a method when user taps the banner. Quoting from the iAd Programming Guide (http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/iAd_Guide/WorkingwithBannerViews/WorkingwithBannerViews.html#//apple_ref/doc/uid/TP40009881-CH4-SW3); ~~~ Responding to a Touch in the Banner View Before the banner view triggers an advertising action, it calls the delegate’s bannerViewActionShouldBegin:willLeaveApplication: method. Your delegate method performs two tasks: It decides whether to allow the action to be triggered. If the action will cover your application’s user interface, this method pauses any activities that require user interaction. Your delegate should return YES from this method if it wants to allow the action to be triggered. It can prevent the action from being triggered by returning NO. Your application should always allow actions to be triggered unless it cannot safely do so. If the willLeave parameter is YES, then your application is going to be moved to the background after it returns from this delegate method. This process is described in “Understanding an Application’s States and Transitions” in iOS App Programming Guide. If the willLeave parameter is NO, iAd covers the application’s user interface after it returns from this delegate method. Your application should disable sounds, animations or other activities that require user interaction before returning. For example, a real-time game should pause gameplay, then return YES to allow the action to be triggered. ~~~ This functionality should be exposed as an event. Otherwise Ti.UI.iOS.AdView is useless.
Our documents indicate the 'action' event should fire when a "banner action" has taken place. http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.iOS.AdView-event-action Reports from our Titans indicate this used to work. Likely a regression. Please reinvestigate and fix.
This is still an issue, when will a fix be in place? Ti sdk 3.4.1 GA Ti Studio build 3.4.1.201410281727 Native there is a property (or variable in swift) - "actionInProgress", which would indicate something is happening with the ad. But an Ti-event would be better.
Closing ticket as iAd is no longer supported.