iphoneobjective-cios5xcode4.2mobclix

How to programmatically check whether Mobclix advertisement is running or not?


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?


Solution

  • 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.