2

I have integrated RevMobAds in my app. How can I check whether a RevMob session has started or not?

In the AppDelegate :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [RevMobAds startSessionWithAppID:@"My RevMob AppID"];
    return YES;
}

-(void)showAds
{
    banner = [[RevMobAds session] banner]; //banner is an object of RevMobBanner
    banner.delegate = self;
    [banner showAd];
}

In my first ViewController :

-(void)displayAd
{
    STAppDelegate *appDelegate = (STAppDelegate *)[UIApplication sharedApplication].delegate;
    [appDelegate showAds];
}

When I call the displayAd function in the viewDidLoad of the first page, some warnings are displayed:-

WARNING: SESSION NOT STARTED!! UNEXPECT BEHAVIOUR CAN OCCOUR!!
WARNING: USING ADS WITHOUT STARTING A SESSION COULD PRODUCE UNPREDICTED BEHAVIOUR!

Also the ad is not displayed. But when I call the displayAd function after a delay,say 5sec, then everything works well and the ad is displayed, but the problem is that this time interval of 5 secs may vary from time to time. So, can anyone suggest me a way to find out whether the RevMob session has started or not so that I can call the displayAd function only after that?

NITHIN S
  • 231
  • 1
  • 2
  • 6

1 Answers1

1
[RevMobAds startSessionWithAppID:REVMOB_APP_ID
              withSuccessHandler:^{
                  NSLog(@"RevMobAds session started");
              } andFailHandler:^(NSError *error) {
                  NSLog(@"RevMobAds session failed");
              }];
zeeawan
  • 6,667
  • 2
  • 50
  • 56
  • Can you please provide more informations and an explanation what the OP did wrong and how your code fix it? It's just what a quality answer is about. – Julian F. Weinert Feb 07 '15 at 00:40
  • @Julian, my code snippet answers the question, "How can I check whether a Revmob Session has started or not?" using the block instead of delegate method. So, I thought that anyone else would find it useful who lands here. – zeeawan Feb 07 '15 at 06:36
  • If I do this way then how would I set delegate. currently I am using [RevMobAds startSessionWithAppID:REVMOB_APP_ID andDelegate:self]; – Alok C Aug 27 '15 at 05:41
  • @Alix, you can start the session this way. And utilise session anywhere in the app and can also set delegate as shown in the following snippet. RevMobFullscreen *revMob; revMob = [[RevMobAds session] fullscreen]; revMob.delegate = self; – zeeawan Aug 27 '15 at 15:22
  • @zeeawan : Yup I did the same. But my delegate methods are not bring called thats why I went to andDelegate approach. but thats also not working. I am confused. :/ any suggestion for me – Alok C Aug 27 '15 at 15:35
  • Well, startSessionWithAppID should succeed or return an error. – zeeawan Aug 27 '15 at 17:51