Search code examples
iosios6delegatesrevmob

RevMobAds delegate issue


I am trying to receive RevMobAdsDelegate events in my AppDelegate and they are not being called. See below what I have done:

1) Implement RevMobAdsDelegate protocol:

@interface MyiOSAppAppDelegate : UIResponder <UIApplicationDelegate, RevMobAdsDelegate>

2) Initializing RevMobAds with ID:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // other code here..
    // Revmob initialization
    [RevMobAds startSessionWithAppID: @"SECRET_APP_ID"];
    // other code here..
}

3) Calling RevMob Ad:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [[RevMobAds session] showFullscreen];
}

4) Declaring RevMobAdsDelegate events:

- (void) revmobAdDidFailWithError:(NSError *)error
{
    NSLog(@"1");
}

- (void) revmobAdDidReceive
{
    NSLog(@"2");
}

- (void) revmobAdDisplayed
{
    NSLog(@"3");
}

- (void) revmobUserClickedInTheAd
{
    NSLog(@"4");
}

- (void) revmobUserClosedTheAd
{
    NSLog(@"5");
}

Ads are appearing fine and there is no problem with that, but none of the above functions are being called. I also tried

[RevMobAds session].delegate = self;

but nothing happened. This last line is not mentioned anywhere in RevMobAds Documentation
but I still tried. Can anyone help how I can call these events?

Any help here will be much appreciated.


Solution

  • The delegates are only available with the object ads, check the API Documentation.

    But you can use something like this:

    RevMobFullscreen *ad = [[RevMobAds session] fullscreen];
    ad.delegate = self;
    [ad showAd];
    

    Or you can use the new block "delegates":

     RevMobFullscreen *ad = [[RevMobAds session] fullscreen];
     [ad loadWithSuccessHandler:^(RevMobFullscreen *fs) {
       [fs showAd];
       NSLog(@"Ad loaded");
     } andLoadFailHandler:^(RevMobFullscreen *fs, NSError *error) {
       NSLog(@"Ad error: %@",error);
     } onClickHandler:^{
       NSLog(@"Ad clicked");
     } onCloseHandler:^{
       NSLog(@"Ad closed");
     }];