Skip to content

Use Ramptiv SDK

Initialize Ramptiv SDK

If you have already installed the Ramptiv SDK in your app, let's start initializing the SDK.

1
2
3
4
5
6
import RamptivMobileAds

RamptivAds.shared.initialize(with: orgApiKey, 
                             and: appApiKey,
                             onInitializationSuccess: { message in print(message) },
                             onInitializationError: { message in print(message) })
To initialize Ramptiv SDK with Organization API Key and App API Key. The onInitializationSuccess and onInitializationError are the callbacks to track whether the initialization is successful or not. After successful initialization, your app is ready to load and view ads.

Note

Get your Organization API Key and App API Key from your app list.

Load Ramptiv Ad (image and video)

If you have successfully initialized the Ramptiv SDK, your app is ready to load ad.

1
2
3
RamptivAds.shared.loadAd(for: placementApiKey,
                         onLoadSuccess: { message in print(message) },
                         onLoadError: { message in print(message) })
To load Ramptiv ad for Placement API Key. The onLoadSuccess and onLoadError are the callbacks to track whether the ad is loaded successfully or not. After successfully loading ads, your app is ready to view ads.

Note

Get your Placement API Key from your app's monetization list.

View Ramptiv Ad (image and video)

1
2
3
RamptivAds.shared.viewAd(for: placementApiKey,
                         onViewSuccess: { message in print(message) },
                         onViewError: { message in print(message) })
To view Ramptiv ad for Placement API Key. The onViewSuccess and onViewError are the callbacks to track whether the ad is viewed successfully or not.

Load Ramptiv banner

1
2
3
4
5
6
RamptivAds.shared.loadBanner(for: placementApiKey, 
                             position: "BOTTOM",
                             onLoadSuccess: { message in print(message) },
                             onLoadError: { message in print(message) },
                             onViewSuccess: { message in print(message) },
                             onViewError: { message in print(message) })
So, load Ramptiv banner for Placement API Key and position at BOTTOM or TOP. The onLoadSuccess and onLoadError are the callbacks to track whether the banner is loaded successfully or not. And onViewSuccess and onViewError are to track whether the banner is viewed successfully or not. After successfully loading ads, your app is ready to view ads.

Note

Unlike image and video ads, banner ad isn't needed to be load and view individually. RamptivAds.shared.loadBanner(...) loads the banner and views immediately after loading. Position value "TOP" will place the banner at the top, any other value will place the banner at the bottom.

Close Ramptiv Banner

RamptivAds.shared.closeBanner(for: placementApiKey)

It's not recommended to close banner ads. But if a developer finds it necessary in situations like user has paid not to show banner, in that case, close a banner for that particular placement.