2

I have used the MobClix for ad in my app. Now I want to check whether the advertisement is there or not, programmatically, so that i can put hard coded image instead the ad.

How can I check it?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rohan
  • 2,939
  • 5
  • 36
  • 65

1 Answers1

6

Use the MobClix built in house-ads feature (your own ads) when they have no ad to show.

EDIT:

Checking the docs I can see that there is didFailLoadWithError method:

-(void)adView:(MobclixAdView*)adView didFailLoadWithError:(NSError*)error

There's also some errors you can check for:

kMCAdsUnknownError
kMCAdsUnavailable
kMCAdsDisabled

I guess therefore that you could wait for an ad request to fail and then show your image. Problem is, the fail might only be temporary, but you wouldn't know to re-start checking for ads so you'd need to do that on a timer after x mins.

p.s. I still think you should just display your image via Mobclix in-house custom ad.

EDIT 2:

in your header file put:

- (void)adView:(MobclixAdView*)adView didFailLoadWithError:(NSError*)error;

in your implementation file put:

- (void)adView:(MobclixAdView*)adView didFailLoadWithError:(NSError*)error {
    NSLog(@" error  : %@", error);
    NSLog(@"Ad error code: %d", [error code]);
}

then you should be able to just check which error code you have and act accordingly.

ader
  • 5,403
  • 1
  • 21
  • 26
  • thanks for replay. But i want to programmatically check whether the addvertisement is running or not ? so that i can set hard coded image when there is no ad. – Rohan Feb 28 '12 at 11:58
  • once again thanks for replay. But i want to know where should i use this method i.e. in my AppDelegate or ViewController ? and how how can i check for the error ? Thanks.. – Rohan Feb 28 '12 at 13:56
  • 1
    I would do it where you are implementing the adView. e.g. if you are adding your adView to a navigationController, add the method there. If you are adding the adView to your viewController add the method there. Try implementing it and come back with code that you find isn't working. – ader Feb 28 '12 at 14:34
  • i am really thankful to you for taking interest in solving my problem. Now i am clear that i have to use this method in my viewContorller. But i want to know how can i use that error code (i.e. -503 for kMCAdsUnavailable) which is of enum type , so that i can check it out that there is no ad avilable? Thanks.. – Rohan Feb 29 '12 at 04:34