We use listViews instead of tableViews because of better performance, so we needed to add the bannerView to a listView. Because of the different structure of listViews we couldn't add it after the listView was generated, and I had to solve it with a definition of the bannerView in a listView template.
This seemed to be working, until I forgot to define a valid adUnitId: it caused a very ugly crash:
[WARN] : 2016-02-20 20:01:29.254 Skoften[94744:9830716] <Google> To get test ads on this device, call: request.testDevices = @[ kGADSimulatorID ];
[WARN] : 2016-02-20 20:01:29.394 Skoften[94744:9830816] <Google> Invalid Request: {
[WARN] : "activation_overlay_url" = "http://googleads.g.doubleclick.net/mads/static/activation_overlay.html?hl=en-us";
[WARN] : "base_uri" = "https:";
[WARN] : "drt_include" = 0;
[WARN] : "enable_auto_click_protection" = 1;
[WARN] : errors = "Cannot determine request type. Is your ad unit id correct?";
[WARN] : "google.afma.Notify_dt" = 1455994889393;
[WARN] : "pan_include" = 0;
[WARN] : "request_id" = 1;
[WARN] : "request_scenario" = "online_request";
[WARN] : type = unknown;
[WARN] : "use_webview_loadurl" = 0;
[WARN] : }
[ERROR] : The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] : Reason:
[ERROR] : *** setObjectForKey: object cannot be nil (key: section)
[ERROR] : Stack trace:
[ERROR] :
[ERROR] : 0 CoreFoundation 0x0000000108541e4d __exceptionPreprocess + 141
[ERROR] : 1 libobjc.A.dylib 0x0000000107f13deb objc_exception_throw + 48
[ERROR] : 2 CoreFoundation 0x000000010843f6e2 -[__NSDictionaryM setObject:forKey:] + 1042
[ERROR] : 3 Skoften 0x0000000101c1898a -[TiUIListItemProxy overrideEventObject:forEvent:fromViewProxy:] + 362
[ERROR] : 4 Skoften 0x00000001019ea7bf -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 303
[ERROR] : 5 Skoften 0x0000000101a82e9b -[TiProxy fireEvent:withObject:] + 139
[ERROR] : 6 Skoften 0x00000001022d48dd -[TiAdmobView adView:didFailToReceiveAdWithError:] + 134
[ERROR] : 7 Skoften 0x0000000101c9fa14 __54-[GADBannerView slot:didFailToLoadAdContentWithError:]_block_invoke + 83
[ERROR] : 8 Skoften 0x0000000101cd8feb GADDispatchAsyncSafeMainQueue + 45
[ERROR] : 9 Skoften 0x0000000101c9f99e -[GADBannerView slot:didFailToLoadAdContentWithError:] + 111
[ERROR] : 10 Skoften 0x0000000101cc3cd4 -[GADSlot(AdEvents) adFailedToReceiveContentWithError:] + 82
[ERROR] : 11 Skoften 0x0000000101ce6b58 -[GADSlot(State) didFailToReceiveAdWithError:shouldCancelPendingActions:] + 135
[ERROR] : 12 Skoften 0x0000000101cb5569 -[GADSlot(GADSDKCoreControllerDelegate) invalidJavaScriptRequest] + 112
[ERROR] : 13 Skoften 0x0000000101c83375 __87-[GADSDKCoreController SDKCoreGMSGHandler:didReceiveInvalidAdWithRequestID:parameters:]_block_invoke736 + 34
[ERROR] : 14 libdispatch.dylib 0x000000010bf74d59 _dispatch_call_block_and_release + 12
[ERROR] : 15 libdispatch.dylib 0x000000010bf904a7 _dispatch_client_callout + 8
[ERROR] : 16 libdispatch.dylib 0x000000010bf7af2d _dispatch_main_queue_callback_4CF + 714
[ERROR] : 17 CoreFoundation 0x00000001084a1d09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[ERROR] : 18 CoreFoundation 0x00000001084632c9 __CFRunLoopRun + 2073
[ERROR] : 19 CoreFoundation 0x0000000108462828 CFRunLoopRunSpecific + 488
[ERROR] : 20 GraphicsServices 0x000000010993bad2 GSEventRunModal + 161
[ERROR] : 21 UIKit 0x0000000103542610 UIApplicationMain + 171
[ERROR] : 22 Skoften 0x00000001019a59f6 main + 310
[ERROR] : 23 libdyld.dylib 0x000000010bfbf92d start + 1
[ERROR] :
[ERROR] : 2016-02-20 20:01:29.405 Skoften[94744:9826279] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: section)'
[ERROR] : *** First throw call stack:
[ERROR] : (
[ERROR] : 0 CoreFoundation 0x0000000108541e65 __exceptionPreprocess + 165
[ERROR] : 1 libobjc.A.dylib 0x0000000107f13deb objc_exception_throw + 48
[ERROR] : 2 CoreFoundation 0x000000010843f6e2 -[__NSDictionaryM setObject:forKey:] + 1042
[ERROR] : 3 Skoften 0x0000000101c1898a -[TiUIListItemProxy overrideEventObject:forEvent:fromViewProxy:] + 362
[ERROR] : 4 Skoften 0x00000001019ea7bf -[TiViewProxy fireEvent:withObject:propagate:reportSuccess:errorCode:message:] + 303
[ERROR] : 5 Skoften 0x0000000101a82e9b -[TiProxy fireEvent:withObject:] + 139
[ERROR] : 6 Skoften 0x00000001022d48dd -[TiAdmobView adView:didFailToReceiveAdWithError:] + 134
[ERROR] : 7 Skoften 0x0000000101c9fa14 __54-[GADBannerView slot:didFailToLoadAdContentWithError:]_block_invoke + 83
[ERROR] : 8 Skoften 0x0000000101cd8feb GADDispatchAsyncSafeMainQueue + 45
[ERROR] : 9 Skoften 0x0000000101c9f99e -[GADBannerView slot:didFailToLoadAdContentWithError:] + 111
[ERROR] : 10 Skoften 0x0000000101cc3cd4 -[GADSlot(AdEvents) adFailedToReceiveContentWithError:] + 82
[ERROR] : 11 Skoften 0x0000000101ce6b58 -[GADSlot(State) didFailToReceiveAdWithError:shouldCancelPendingActions:] + 135
[ERROR] : 12 Skoften 0x0000000101cb5569 -[GADSlot(GADSDKCoreControllerDelegate) invalidJavaScriptRequest] + 112
[ERROR] : 13 Skoften 0x0000000101c83375 __87-[GADSDKCoreController SDKCoreGMSGHandler:didReceiveInvalidAdWithRequestID:parameters:]_block_invoke736 + 34
[ERROR] : 14 libdispatch.dylib 0x000000010bf74d59 _dispatch_call_block_and_release + 12
[ERROR] : 15 libdispatch.dylib 0x000000010bf904a7 _dispatch_client_callout + 8
[ERROR] : 16 libdispatch.dylib 0x000000010bf7af2d _dispatch_main_queue_callback_4CF + 714
[ERROR] : 17 CoreFoundation 0x00000001084a1d09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
[ERROR] : 18 CoreFoundation 0x00000001084632c9 __CFRunLoopRun + 2073
[ERROR] : 19 CoreFoundation 0x0000000108462828 CFRunLoopRunSpecific + 488
[ERROR] : 20 GraphicsServices 0x000000010993bad2 GSEventRunModal + 161
[ERROR] : 21 UIKit 0x0000000103542610 UIApplicationMain + 171
[ERROR] : 22 Skoften 0x00000001019a59f6 main + 310
[ERROR] : 23 libdyld.dylib 0x000000010bfbf92d start + 1
[ERROR] : )
[ERROR] : libc++abi.dylib: terminating with uncaught exception of type NSException
exports.dfpTemplate = {
properties : {
selectionStyle:Titanium.UI.iPhone.ListViewCellSelectionStyle.NONE,
height : Ti.UI.SIZE,
backgroundColor : 'transparent',
className: 'dfpRow',
name: 'dfpRow'
},
childTemplates : [
{
type : 'Ti.UI.View',
bindId : 'container',
properties : {
width: '100%',
height: 1,
backgroundColor: 'transparent'
},
childTemplates : [
{
type : 'TiAdmob.View',
bindId : 'adDetail',
properties : {
adBackgroundColor : "#FF8800",
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
adUnitId : "ca-app-pub-xxxx/xxxxx",
autoResize : 1,
backgroundColorTop : "#738000",
borderColor : 'red',
linkColor : "#0000FF",
textColor : "#000000",
urlColor : "#00FF00"
}
}
]
}
]
};