Quick Start

This chapter will explain the procedure for displaying the advertisement in the application and measuring the effectiveness of the advertisement.
For the details, please refer to 3.Programming Guide.

The following guide shows an example based on UITableView, but it may be used in other cases such as UIView.

Prerequisites

  • Following Installation Guide to import the SDK into your application.

  • Register from the management screen to issue the Media ID and advertising framework ID(adSpotId) . (At the current stage, inquiries should be made to the representative)

Media ID uses the app identification.
Advertising framework ID (adSpotId) is a unique identifier used to distinguish an advertisement framework, See Acquisition of advertising framework ID for details on advertising framework ID.

Initializing the SDK

RFP is initialized with the Media ID acquired as described above as the argument.

Unless there is a particular reason, stipulate as

UIApplicationDelegate application(_:didFinishLaunchingWithOptions:)

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    RFP.rfpInitMedia("your_media_id")

    return true
}

Please note that unless initialization takes place, the general acquisition of advertisements, to be described later, cannot be performed.

Loading advertisements

Advertising framework ID(adSpotId) and positions for advertisements’ indexes in the UITableView and advertisements’ counts are needed. As position is used in the advertising results analysis, use this as reference when determining the position within the screen.

Please set listed three arguments and call ‘rfpLoadAd’ to load advertisements.

Argument Usage
adSpotId advertisements’ framework ID
adCount advertisements’ counts
positions advertisements’ indexes

The following guide shows an example based on UITableView, but it may be used in other cases such as UIView.
Set positions = [0] means insert advertisement to the head of UITableView, positions = [1, 4] means insert advertisements to the second and fifth indexes of UITableView.
positions = [0] also may be used in other layout with one advertisement.

image of positions = [1, 4]

class YourViewController: UIViewController, RFPInstreamAdLoaderDelegate {

    let instreamAdLoader = RFPInstreamAdLoader.init()
    // Advertising framework ID
    let adSpotId = "your_adspot_id"
    // insert 2 advertisements into UITableView
    let positions = [1, 4]

    override func viewDidLoad() {
        super.viewDidLoad()

        // set delegate
        instreamAdLoader.delegate = self
        // load Advertisements
        instreamAdLoader.rfpLoadAd(
            withReturn: adSpotId,
            adCount: UInt(positions.count),
            positions: positions
        )
    }
}

Displaying advertisements

Display the advertisements based on the information acquired from RFPInstreamInfoModel.

// RFPInstreamAdLoaderDelegate methods
// ads finished load
func rfpInstreamAdLoaderDidFinishLoadingAd(withReturn instreamAdLoader: RFPInstreamAdLoader!, instreamInfoModels: [Any]!) {
    // get ads' information
    for model: RFPInstreamInfoModel in instreamInfoModels as! [RFPInstreamInfoModel] {
        if (model.title) {
            // ad's title
            titleLabel.text = model.title
        }

        if (model.content) {
            // ad's label
            contentLabel.text = model.content
        }
        // load ad's image
        model.rfpLoadImage(imageView, completion: { error -> Void in
            print("Load Finish.")
            if (error != nil) {
                print("Load Error.", error!)
            } else {
                // after image load finished, send impression event
                instreamAdLoader.rfpMeasureImp(model)
            }
        })
    }
    // ... update UITableView ...
    tableView.realoadData();
}

For image loading processing, we recommend to use the common image load library such as SDWebImage

Sending advertisements events

For measuring the advertisement’s, it is necessary to notify the events of the advertisement.

Event Notify Timing
impression when advertisement’s display is completed
click when advertisement is clicked

Notifying impression

After advertisement displayed, please call RFPInstreamAdLoader.rfpMeasureImp(_:) to send impression event.

// model: RFPInstreamInfoProtocol!
RFPInstreamAdLoader.rfpMeasureImp(model)

Processing transitions when clicking advertisements

When the advertisement is clicked, user is appropriately transitioned by calling the following method.

// model: RFPInstreamInfoProtocol!
RFPInstreamAdLoader.rfpSendClickEvent(model)

Timing of impression notification

In order to guarantee that advertisements are viewable, this SDK recommends viewable impression.
You need to implement viewable impression in your application. And we also provide RFPVisibilityTracker to support viewable impression. For the details, please refer to Library Support for Viewable Impression.

Advertisement’s viewable impression must satisfy the impression conditions and must satisfy the following.

Advertisement’s type conditions
Display ads condition1. at least 50% of the advertisement is visible
condition2. visible for at least 1 second
Video ads condition1. at least 50% of the advertisement is visible
condition2. visible for at least 2 consecutive seconds

Ad's viewable impression

More details, please refer to JIAA(Japanese), and IAB/MRC(English).