Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"viewcontroller" no longer provided to AdMob custom event adapter requestAdWithSize() #78

Open
andre-arsenault opened this issue Apr 4, 2019 · 1 comment

Comments

@andre-arsenault
Copy link

Hello. I am upgrading from iOS SDK 3.5.4 to 3.6.1 and during testing I discovered that there has been a breaking change to Custom Event Adapters on iOS and my Google AdMob adapter would no longer display banner ads.

The issue is that viewcontroller is no longer part of the NSDictionary parameter passed to Custom Event Adapter's requestAdWithSize() method. This results in the AdMob GADRequest failing with the following error:

<Google> You must set the rootViewController property of <GADInternalBannerView: 0x103364250; frame = (0 0; 320 50); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x283d79f20>> before loading a request.

Inspecting contents of the NSDictionary showed that the parent entry is an instance of MobFoxAd, so as a work-around, passing that object to GADBannerView.rootViewController seems to work just fine. Is this your new recommended solution?

For completeness here is the contents of the NSDictionary being passed to the Custom Event Adapter's requestAdWithSize() method as of iOS SDK 3.6.1:

{
    "adspace_height" = 50;
    "adspace_width" = 320;
    "c_customevents" = 1;
    "c_mraid" = 2;
    "dev_js" = 1;
    "o_iosadvid" = "D07DFB30-3252-4273-BCF6-4597AA759BC1";
    parent = "<MobFoxAd: 0x103b2fde0; frame = (47 686; 320 50); layer = <CALayer: 0x280381860>>";
    rt = "iphone_app";
    s = 9d46ae5307027e30b77fc88046f8a084;
    skip = 0;
    "sub_bundle_id" = "com.snowleopardgames.lifetotal";
    subid2 = LifeTotal;
    subid3 = "com.snowleopardgames.lifetotal";
    subid4 = "2.0.0";
    u = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57";
    v = "3.6.1_core";
}

And the same dictionary using iOS SDK 3.5.4:

{
    "adspace_height" = 50;
    "adspace_width" = 320;
    "c_customevents" = 1;
    "c_mraid" = 2;
    "dev_js" = 1;
    "o_iosadvid" = "D07DFB30-3252-4273-BCF6-4597AA759BC1";
    parent = "<MobFoxAd: 0x1051466e0; frame = (47 686; 320 50); layer = <CALayer: 0x2839e06a0>>";
    rt = "iphone_app";
    s = 9d46ae5307027e30b77fc88046f8a084;
    skip = 0;
    "sub_bundle_id" = "com.snowleopardgames.lifetotal";
    u = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16D57";
    v = "3.5.4_core";
    viewcontroller = "<MainViewController: 0x1051094b0>";
}

Assuming this isn't a bug, please take care to address breaking issues such as this in future release notes. Thank you!

@andre-arsenault
Copy link
Author

Upon further testing of the same issue with my custom event adapter for Amazon MobAds on iOS, the same issue came up but the work-around I suggested above proved to be incorrect.

Using the value of parent as the root view controller is a bad idea, since MobFoxAd isn't actually a UIViewController. In the case of Amazon MobAds, this results in a crash because MobFoxAd doesn't handle the selector -interfaceOrientation.

Some more Googling led me to use this code to determine my app's root view controller and pass it on to both AdMob and MobAds in my custom event adapters:

[[[[UIApplication sharedApplication] delegate] window] rootViewController];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant