RevMob iOS SDK - Quick Start



It takes 4 simple steps to start monetizing:

  1. Sign up, register your media and get your Media Id
  2. Download it
  3. Add it and the other required frameworks to your project
  4. Insert some code

Sign Up

  1. Sign up through our home page
  2. Click on Monetization on the grey bar menu
  3. On the bottom of the page, click on 'Add iOS App' and fill in the form (it's a good practice to start with Testing Mode with ads to see how the SDK works before publishing your app, but don't forget to turn it off)
  4. You'll now find your app on Monetization page. Get your Media ID there, we'll use it in a minute: media_id

Download

Download ios - 9.0.6


Add Framework

Requirements: iOS 5+ or higher and XCode 4.6 or higher. Legacy versions can be downloaded.

xcode1

xcode2

Double check that you can see RevMobAds.framework in your project:

xcode3

You can do that by clicking on the project root > Build Phases > Link Binary With Libraries > Click in the + button.

Alternatively, you can click on Editor > Add Build Phase > Add Link Binary With Library Phase.

xcode4

If you're programming in Swift, we have a few extra steps that you can find here.

Basic Code

Alright, we're almost there! All we need to do now is import the SDK, Start RevMob's session and add an ad.

"To Start RevMob's session" means to establish communication with our servers. You can only use advertising methods after you receive the confirmation that it's started through its "success handler".

On this example, we'll show a fullscreen ad when we get the success response:

On your ViewController.m file (here's where we'll use the Media ID you got in the Sign Up session):

#import <RevMobAds/RevMobAds.h>

@implementation YourViewController

- (void)viewDidLoad{
    [RevMobAds startSessionWithAppID:@"COPY_YOUR_MEDIA_ID_HERE"
     withSuccessHandler:^{
         [[RevMobAds session] showFullscreen];
     } andFailHandler:^(NSError *error) {
        //For now we don't need this
     }];

     // Your initialization code
}

//Your other functions

@end

With this code you're ready to show some ads! Come on, give it a try!

If you want a bit more of complexity, check the next session.

If you want other ad units (native link, native button, banner, popup, video or rewarded video), check our full guide.

Intermediate Code (optional)

RevMob's SDK can also pre-cache ads and try things again when they fail.

To do that, we'll use RevMob's delegates (event handlers, called listeners in Android), so we have to include RevMobAdsDelegate protocol in your YourUIViewController.h file (you can also use your AppDelegate):

#import <UIKit/UIKit.h>
#import <RevMobAds/RevMobAds.h>
#import <RevMobAds/RevMobAdsDelegate.h>

@interface YourUIViewController : UIViewController <RevMobAdsDelegate>
@end

Pre-caching

You can pre-cache an ad and control when you want to show it. In this example, we'll show it in the fantasy method callGameOverScene in YourUIViewController.m implementation file:

#import "YourUIViewController.h"
#import <RevMobAds/RevMobAds.h>

@property (nonatomic, assign) BOOL adLoaded;
@property (nonatomic, strong) RevMobFullscreen *fullscreen;

@implementation YourUIViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    adLoaded = NO;
    [RevMobAds startSessionWithAppID:@"COPY_YOUR_MEDIA_ID_HERE" andDelegate:self];

    return YES;
}

- (void)loadFullscreen {
    self.fullscreen = [[RevMobAds session] fullscreen];
    self.fullscreen.delegate = self;
    [self.fullscreen loadAd];
}

- (void)callGameOverScene {
    //Let's pretend this is a game and there's a game over scene. This is where it's called.
    //We want to show the fullscreen ad here, but only if it's ready to show:
    if (adLoaded && self.fullscreen) [self.fullscreen showAd];
}


/////RevMob Delegates/////
- (void)revmobSessionIsStarted {
    //As soon as RevMob SDK is initialized, load a fullscreen ad
    [self loadFullscreen];
}

- (void)revmobAdDidReceive {
    //Ad was received. You can show it whenever you want now
    adLoaded = YES;
}

- (void)revmobAdDisplayed {
    //Reset adLoaded after ad is displayed
    adLoaded = NO;
}

@end

You could also put [self.fullscreen showAd]; right inside revmobAdDidReceive, so it shows as soon as it's loaded.

Try things again when they fail

What if the Start Session or an ad request fails? We have specific delegates for those cases, enabling you to try again:

#import "YourUIViewController.h"
#import <RevMobAds/RevMobAds.h>

@property (nonatomic, assign) BOOL adLoaded;
@property (nonatomic, strong) RevMobFullscreen *fullscreen;

@implementation YourUIViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    adLoaded = NO;
    [self startRevMobSession];

    return YES;
}

-(void) startRevMobSession {
    [RevMobAds startSessionWithAppID:@"COPY_YOUR_MEDIA_ID_HERE" andDelegate:self];
}

- (void)loadFullscreen {
    self.fullscreen = [[RevMobAds session] fullscreen];
    self.fullscreen.delegate = self;
    [self.fullscreen loadAd];
}

- (void)callGameOverScene {
    //Let's pretend this is a game and there's a game over scene. This is where it's called.
    //We want to show the fullscreen ad here, but only if it's ready to show:
    if (adLoaded && self.fullscreen) [self.fullscreen showAd];
}


/////RevMob Delegates/////
- (void)revmobSessionIsStarted {
    //As soon as RevMob SDK is initialized, load a fullscreen ad
    [self loadFullscreen];
}

- (void)revmobSessionNotStarted:(NSError *)error {
    [self startRevMobSession];
}

- (void)revmobAdDidReceive {
    //Ad was received. You can show it whenever you want now
    adLoaded = YES;
}

- (void)revmobAdDisplayed {
    //Reset adLoaded after ad is displayed
    adLoaded = NO;
}

- (void)revmobAdDidFailWithError:(NSError *)error {
    //You might want to limit the number of trials here or try a different ad unit
    [self loadFullscreen];
}

@end

We also have delegates that let you know when the user interacts with the ad (sees it, clicks on it, closes it), so you can control your app's behaviour on these cases (change scenes, for example). Check our main delegates on our full guide.

Contact

If you have any issues integrating RevMob SDK, take a look at our SDK Forum.

There you can find other developers' questions & answers that may help you out.

If your problem is a new one, in order to speed up the process, please attach on your post the console logs printed by the following command (it's a summary of your environment information).

RevMob revmob = RevMob.start(this, REVMOB_APP_ID);
revmob.printEnvironmentInformation(this);