larsacus / LARSAdController

Lightweight ad mediation for iOS to properly manage multiple ad networks dynamically including iAd and Google ads.
http://theonlylars.com/blog/2013/01/10/stupid-easy-ads-with-larsadcontroller-3-dot-0/
MIT License
269 stars 60 forks source link

There are no registered ad network adapter classes. #37

Closed igorcarrasco closed 11 years ago

igorcarrasco commented 11 years ago

I get this warning a lot of times:

LARSAdController WARNING [line 521]: There are no registered ad network adapter classes. Please register an ad network class using registerAdClass: before attempting to add ad container view into your view heirarchy.

I do register the adds in My App delegate:

I do: [[LARSAdController sharedManager] registerAdClass:[TOLAdAdapteriAds class]]; [[LARSAdController sharedManager] registerAdClass:[TOLAdAdapterGoogleAds class] withPublisherId:@"xxxxxxxxxxx"];

Any idea what might be causing this? Cause I'm probably losing a lot of ad requests. Best Regards

larsacus commented 11 years ago

Did you clone and integrate the source yourself, or did you use cocoapods? It's very suspect that the warning you are referring to is output on line 508 and not line 521 as the warning you have pasted here specifies.

I'll need some more information to see if there is an issue. If you could, please place #define LARSADCONTROLLER_DEBUG somewhere in your *.pch file to enable logging, then copy/paste the full debug output.

igorcarrasco commented 11 years ago

Nothing seems to Appear:

2013-04-15 20:46:13.052 PinThis[5614:907] LARSAdController WARNING [line 521]: There are no registered ad network adapter classes. Please register an ad network class using registerAdClass: before attempting to add ad container view into your view heirarchy. 2013-04-15 20:46:23.866 PinThis[5614:907] To get test ads on this device, call: request.testDevices = [NSArray arrayWithObjects:@"zzzzzzzzzzzz", nil]; 2013-04-15 20:46:24.670 PinThis[5614:907] Cannot find an ad network adapter with the name(s): ( GADMAdapterIAd ). Remember to link all required ad network adapters and SDKs, and set -ObjC -all_load in the 'Other Linker Flags' setting of your build target.

On Mon, Apr 15, 2013 at 4:50 AM, Lars Anderson notifications@github.comwrote:

Did you clone and integrate the source yourself, or did you use cocoapods? It's very suspect that the warning you are referring to is output on line 508 and not line 521 as the warning you have pasted here specifies.

I'll need some more information to see if there is an issue. If you could, please place #define LARSADCONTROLLER_DEBUG somewhere in your *.pch file to enable logging, then copy/paste the full debug output.

— Reply to this email directly or view it on GitHubhttps://github.com/larsacus/LARSAdController/issues/37#issuecomment-16366317 .

larsacus commented 11 years ago

Are you using cocoa pods or did you clone the source and integrate yourself? It sounds like you didn't set the -ObjC and -all_load flags in your project for the AdMob framework.

igorcarrasco commented 11 years ago

Greetings,

I used the cocoapods.

I have those flags and a bunch of others set in My Project. No flag is set in the Pods Project.

best regards

On Mon, Apr 15, 2013 at 11:04 PM, Lars Anderson notifications@github.comwrote:

Are you using cocoa pods or did you clone the source and integrate yourself? It sounds like you didn't set the -ObjC and -all_load flags in your project for the AdMob framework.

— Reply to this email directly or view it on GitHubhttps://github.com/larsacus/LARSAdController/issues/37#issuecomment-16414428 .

larsacus commented 11 years ago

If you're using cocoapods, you'll need to set the above #define in your pod's prefix.pchfile to get the logs to appear.

igorcarrasco commented 11 years ago

2013-04-16 01:34:44.308 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:34:44.312 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:34:44.315 PinThis[10380:907] LARSAdController WARNING [line 521]: There are no registered ad network adapter classes. Please register an ad network class using registerAdClass: before attempting to add ad container view into your view heirarchy. 2013-04-16 01:34:44.317 PinThis[10380:907] LARSAdController [line 717]: Registering for orientation notifications 2013-04-16 01:34:44.318 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:34:44.320 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:34:44.470 PinThis[10380:907] LARSAdController [line 743]: Handling orientation change 2013-04-16 01:34:44.790 PinThis[10380:907] LARSAdController [line 743]: Handling orientation change 2013-04-16 01:34:44.827 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:34:44.829 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:34:44.839 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:34:44.840 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:36:09.327 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:36:09.329 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:36:09.331 PinThis[10380:907] LARSAdController [line 536]: Creating new instance of adapter class "TOLAdAdapteriAds" 2013-04-16 01:36:09.333 PinThis[10380:907] LARSAdController [line 576]: Successfully created instance of "TOLAdAdapteriAds" 2013-04-16 01:36:09.351 PinThis[10380:907] LARSAdController [line 487]: Initial banner frame : {{0, 50}, {320, 50}} 2013-04-16 01:36:09.356 PinThis[10380:907] LARSAdController [line 187]: View is portrait 2013-04-16 01:36:09.357 PinThis[10380:907] LARSAdController [line 210]: Container frame: {{0, 366}, {320, 50}} 2013-04-16 01:36:19.870 PinThis[10380:907] LARSAdController [line 644]: Ad loaded for iAds! 2013-04-16 01:36:19.878 PinThis[10380:907] LARSAdController [line 512]: Final banner frame : {{0, 0}, {320, 50}} 2013-04-16 01:36:19.896 PinThis[10380:907] TOLAdAdapteriAds [line 107]: iAd did load ad

On Tue, Apr 16, 2013 at 12:38 AM, Lars Anderson notifications@github.comwrote:

If you're using cocoapods, you'll need to set the above #define in your pod's prefix.pchfile to get the logs to appear.

— Reply to this email directly or view it on GitHubhttps://github.com/larsacus/LARSAdController/issues/37#issuecomment-16418099 .

larsacus commented 11 years ago

Just looking at this short output, it appears your ads are running fine. The initial call to addAdContainerToViewInViewController: may be being called before you are registering the ads with the system. But that doesn't make sense if you are registering the ad adapters in application:didFinishLaunching:withOptions:. Ensure you are registering your ad adapters as soon as you can in application:didFinishLaunching:withOptions: and see if that helps. Where is the first place you are adding an ad to your views? It seems like it's only the initial call that's getting hung up.

igorcarrasco commented 11 years ago

Is it because I alloc my root view controller and add it to the navigationcontroller before?

All my calls to the adcontroller are on:

On Tue, Apr 16, 2013 at 3:27 AM, Lars Anderson notifications@github.comwrote:

Just looking at this short output, it appears your ads are running fine. The initial call to addAdContainerToViewInViewController: may be being called before you are registering the ads with the system. But that doesn't make sense if you are registering the ad adapters in application:didFinishLaunching:withOptions:. Ensure you are registering your ad adapters as soon as you can in application:didFinishLaunching:withOptions: and see if that helps. Where is the first place you are adding an ad to your views? It seems like it's only the initial call that's getting hung up.

— Reply to this email directly or view it on GitHubhttps://github.com/larsacus/LARSAdController/issues/37#issuecomment-16423289 .

larsacus commented 11 years ago

Yes. You are registering your ad adapters after you are creating your view controller and adding it to the window, which is trying to display an ad before it knows what ads it is supposed to display. Just move the call to register your ad adapters before any calls related to your view controller and you shouldn't have the issue anymore.

igorcarrasco commented 11 years ago

Thanks.

Btw I'm working in an App ATM that requires callback to when an ad is going to display,going to hide.

Right now I made my own obervers: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(adWillShow) name:@"adWillShow" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(adWillHide) name:@"adWillHide" object:nil];

And I'm trigering them:

Is there a built in way to get notifications?

I found this in your code: /* A boolean flag that indicates if any ads are currently being displayed. @discussion Value change will be triggered when any ads have a visibility state change. Key-value observable. / @property (nonatomic, getter = isAdVisible, readonly) BOOL adVisible;

But haven't found an example on how to implement it! best regards

On Tue, Apr 16, 2013 at 2:16 PM, Lars Anderson notifications@github.comwrote:

Yes. You are registering your ad adapters after you are creating your view controller and adding it to the window, which is trying to display an ad before it knows what ads it is supposed to display. Just move the call to register your ad adapters before any calls related to your view controller and you shouldn't have the issue anymore.

— Reply to this email directly or view it on GitHubhttps://github.com/larsacus/LARSAdController/issues/37#issuecomment-16443791 .

larsacus commented 11 years ago

You can add what's called a key-value observer to watch the adVisible property for changes. I've included a key in LARSAdController.h, kLARSAdObserverKeyPathIsAdVisible, that you can use to observe this property. Whenever it's value changes, this means that the status of visible ads has changed.

The basics of KVO are:

Register observer: [[LARSAdController sharedManager] addObserver:self forKeyPath:kLARSAdObserverKeyPathIsAdVisible options:NSKeyValueObservingOptionNew context:nil];

Observe changes by implementing in your observer:

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context
{
    if ([keyPath isEqualToString:kLARSAdObserverKeyPathIsAdVisible]) {
        //handle change here
    }
}

You can find more info about KVO here: http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/KeyValueObserving/Articles/KVOBasics.html#//apple_ref/doc/uid/20002252-BAJEAIEE