-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Using the provided Custom Event code for Amazon MobileAds on iOS, the hosting Cordova app will crash as soon as a banner ad is served.
2017-10-09 10:33:33.287163+0100 LifeTotal[12059:2087642] dbg: ### Amazon: loadAd ###
2017-10-09 10:33:33.375416+0100 LifeTotal[12059:2087642] -[MobFoxPlugin interfaceOrientation]: unrecognized selector sent to instance 0x1c028fe10
2017-10-09 10:33:33.376815+0100 LifeTotal[12059:2087642] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MobFoxPlugin interfaceOrientation]: unrecognized selector sent to instance 0x1c028fe10'
*** First throw call stack:
(0x181d2bd38 0x181240528 0x181d391f8 0x181d316e4 0x181c170dc 0x104412960 0x10441248c 0x104412670 0x10440eb6c 0x10441cd74 0x1044142e4 0x1044140f0 0x10441cc54 0x10441caac 0x104433dcc 0x10440d710 0x1042e6600 0x1043092e4 0x104f5d49c 0x104f5d45c 0x104f62050 0x181cd3f20 0x181cd1afc 0x181bf22d8 0x183a83f84 0x18b19f880 0x1042c5ba8 0x18171656c)
libc++abi.dylib: terminating with uncaught exception of type NSException
The cause is in MobFoxCustomEventAmazon.m's implementation of -[requestAdWithSize:networkID:customEventInfo:] the line:
self.parentViewController = [info objectForKey:@"viewcontroller_parent"];
In the context of a Cordova app, the object stored in that dictionary is an instance of MobFoxPlugin, which is NOT a UIViewController. However it is a CDVPlugin, so the proper fix is to replace that line with:
MobFoxPlugin *plugin = [info objectForKey:@"viewcontroller_parent"];
self.parentViewController = plugin.viewController;
and import the MobFoxPlugin.h header in this .m file for the definition of MobFoxPlugin.
I'm not sure what type of object is passed in for the "viewcontroller_parent" dictionary entry in non-Cordova apps, so I cannot generalize a fix for everyone else at the moment, if indeed it is even broken at all for non-Cordova apps.