The Nexverse SDK provides a powerful and flexible solution for monetizing your iOS application through various ad formats. This guide walks you through the integration process and demonstrates how to implement each ad type effectively.
Account ID: It is a mandatory parameter to initialise the Nexverse SDK. You can obtain the accountId from Nexverse dashboard.
Config ID: A unique identifier based on the ad format and placement in your app. The SDK uses this ID to request and render appropriate ads for each placement. You can obtain the configId from Nexverse dashboard.
Before using any of the SDK’s features, you must initialize it with your account configuration. This one-time setup should be performed as early as possible in your app’s lifecycle, ideally right after launch.
Here’s how to initialize the SDK in your AppDelegate:
import Nexverse
// ...existing code...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let initConfig = InitConfig(
nexverseAccountId: "replace-with-actual-account-id",
)
NexverseAdManager.initialise(initConfig) { status, error in
switch status {
case .succeeded:
print("SDK initialised successfully.")
case .failed:
print("SDK initialised failed with error: \(error?.localizedDescription ?? "NA").")
case .serverStatusWarning:
print("SDK initialised successfully, but server status check failed with error: \(error?.localizedDescription ?? "NA").")
@unknown default:
print("Unknown error has occurred")
}
}
return true
}
// Import needs to be added to .h files.
@import Nexverse; // OR #import <Nexverse/Nexverse.h>
// ...existing code...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[NexverseAdManager initialise:config :^(enum NexverseInitializationStatus status, NSError * _Nullable error) {
switch (status) {
case NexverseInitializationStatusSucceeded:
NSLog(@"SDK initialised successfully.");
break;
case NexverseInitializationStatusFailed:
NSLog(@"SDK initialised failed with error: %@", error.localizedDescription);
break;
case NexverseInitializationStatusServerStatusWarning:
NSLog(@"SDK initialised successfully, but server status check failed with error: %@", error.localizedDescription);
break;
default:
NSLog(@"Unknown error has occurred");
}
}];
}
info
Note Please wait for the Nexverse SDK initialisation to be completed before using its functionality. Doing so simultaneously will result in unexpected behaviour.
Based on user’s region and CMP (Consent Management Platform), GDPR (General Data Protection Regulation) properties need to be set.
It should be set while initialising the SDK or before requesting for any ad.
Targeting.shared.subjectToGDPR = true // or false
// No need to set gdprConsentString if subjectToGDPR is set to false.
Targeting.shared.gdprConsentString = "replace-with-actual-consent-string"
[[Targeting shared] setSubjectToGDPR:@1]; // or @0
// No need to set gdprConsentString if subjectToGDPR is set to false.
[[Targeting shared] setGdprConsentString:@"replace-with-actual-consent-string"];
Based on user’s region and age, COPPA (Children’s Online Privacy Protection Act) property needs to be set.
It should be set while initialising the SDK or before requesting for any ad.
Targeting.shared.subjectToCOPPA = true // or false
It is recommended to include location permission in your app to improve ad targeting and provide a better advertising experience.
If your app is not requesting for location permission already then it is recommended to use the method provided by Nexverse SDK to request the permission.
First add the below mandatory key value pair in your Info.plist. Update the value to a proper reason why your app needs location permission. Example: Your app name will use the device location to serve better and targeted ads.
<key>NSLocationWhenInUseUsageDescription</key>
<string>A simple text that describes why your app needs the location</string>
Once your Info.plist is updated with necessary details, invoke the method to request location permission from appropriate place in your app.
NexverseAdManager.requestLocationPermission { status in
switch status {
case .authorizedAlways, .authorizedWhenInUse:
print("Location permission granted.")
case .denied:
print("Location permission denied.")
case .restricted:
print("Location permission restricted.")
case .notDetermined:
print("Location permission not determined.")
@unknown default:
print("Location permission unknown.")
}
}
[NexverseAdManager requestLocationPermissionWithCompletion:^(CLAuthorizationStatus status) {
switch (status) {
case kCLAuthorizationStatusAuthorizedAlways:
case kCLAuthorizationStatusAuthorizedWhenInUse:
NSLog(@"Location permission granted.");
break;
case kCLAuthorizationStatusDenied:
NSLog(@"Location permission denied.");
break;
case kCLAuthorizationStatusRestricted:
NSLog(@"Location permission restricted.");
break;
case kCLAuthorizationStatusNotDetermined:
NSLog(@"Location permission not determined.");
break;
default:
NSLog(@"Location permission unknown.");
break;
}
}];
Once user allows the access to location services, SDK will start using it automatically to serve better and targeted ads. You can change this preference by setting below flag to appropriate value.
Set to true if SDK should be allowed the access to location, otherwise set to false.
Nexverse provides all standard ad formats supported by market leaders. Each format is designed to maximize revenue while maintaining a great user experience.
Banner ads are a reliable way to monetize your app with minimal impact on user experience. The BannerView class handles the loading and display of banner ads, supporting various formats including image, video, and HTML (Rich Media).
Implement these delegate methods to handle banner ad events:
// MARK: - BannerViewDelegate
extension BannerDemoViewController: BannerViewDelegate {
func bannerViewPresentationController() -> UIViewController? {
return self
}
func bannerView(_ bannerView: BannerView, didReceiveAdWithAdSize adSize: CGSize) {
// Handle successful ad load
}
func bannerView(_ bannerView: BannerView, didFailToReceiveAdWith error: any Error) {
// Handle ad load failure
}
func bannerViewWillLeaveApplication(_ bannerView: BannerView) {
// Handle app leaving foreground
}
func bannerViewWillPresentModal(_ bannerView: BannerView) {
// Handle modal presentation
}
func bannerViewDidDismissModal(_ bannerView: BannerView) {
// Handle modal dismissal
}
}
// MARK: - NexverseVideoEventsDelegate
extension BannerViewController: NexverseVideoEventsDelegate {
func onVideoStart() {
// Video started
}
func onVideoFirstQuartile() {
// Video played till first quartile
}
func onVideoMidpoint() {
// Video played till mid point
}
func onVideoThirdQuartile() {
// Video played till third quartile
}
func onVideoComplete() {
// Video played till end
}
func onVideoPause() {
// Video paused
}
func onVideoResume() {
// Video resumed
}
func onVideoMute() {
// Video muted
}
func onVideoUnmute() {
// Video unmuted
}
func onVideoProgress(currentTime: TimeInterval, duration: TimeInterval) {
// Video playback time changed to currentTime
}
func onVideoError(_ error: Error?) {
// Error faced while playing video
}
}
// BannerDemoViewController.h file.
@interface BannerDemoViewController : UIViewController <BannerViewDelegate, NexverseVideoEventsDelegate>
@end
// BannerDemoViewController.m file
@implementation BannerDemoViewController
// MARK: - BannerViewDelegate
- (UIViewController *)bannerViewPresentationController {
/// Asks the delegate for a view controller instance to use for presenting modal views
/// as a result of user interaction on an ad. Usual implementation may simply return self,
/// if it is view controller class.
return self;
}
- (void)bannerView:(BannerView *)bannerView didReceiveAdWithAdSize:(CGSize)adSize {
// Handle successful ad load
}
- (void)bannerView:(BannerView *)bannerView didFailToReceiveAdWith:(NSError *)error {
// Handle ad load failure
}
- (void)bannerViewWillLeaveApplication:(BannerView *)bannerView {
// Handle app leaving foreground
}
- (void)bannerViewWillPresentModal:(BannerView *)bannerView {
// Handle modal presentation
}
- (void)bannerViewDidDismissModal:(BannerView *)bannerView {
// Handle modal dismissal
}
// MARK: - NexverseVideoEventsDelegate
- (void)onVideoStart {
// Video started
}
- (void)onVideoFirstQuartile {
// Video played till first quartile
}
- (void)onVideoMidpoint {
// Video played till mid point
}
- (void)onVideoThirdQuartile {
// Video played till third quartile
}
- (void)onVideoComplete {
// Video played till end
}
- (void)onVideoPause {
// Video paused
}
- (void)onVideoResume {
// Video resumed
}
- (void)onVideoMute {
// Video muted
}
- (void)onVideoUnmute {
// Video unmuted
}
- (void)onVideoProgressWithCurrentTime:(NSTimeInterval)currentTime
duration:(NSTimeInterval)duration {
// Video playback time changed to currentTime
}
- (void)onVideoError:(NSError * _Nullable)error {
// Error faced while playing video
}
@end
Interstitial ads are full-screen advertisements that provide high-impact experiences at natural transition points in your app. The SDK supports both display and video formats through the InterstitialRenderingAdUnit class.
import Nexverse
class InterstitialDemoViewController: UIViewController {
private var interstitialAdUnit: InterstitialRenderingAdUnit!
override func loadView() {
super.loadView()
createAd()
}
func createAd() {
// 1. Create a InterstitialRenderingAdUnit
interstitialAdUnit = InterstitialRenderingAdUnit(configID: "replace-with-actual-config-id")
// 2. Configure the InterstitialRenderingAdUnit
// [.video] for video interstitial & [.video, .banner] for multiformat
interstitialAdUnit.adFormats = [.banner]
interstitialAdUnit.delegate = self
interstitialAdUnit.redirectionType = .externalBrowser // defaults to .internalBrowser
// Set below properties to determine whether video controls are visibile or not.
interstitialAdUnit.isPlaybackButtonVisible = true
interstitialAdUnit.isMuteButtonVisible = true
// 3. Load the interstitial ad
// NOTE: This will just load the ad,
// interstitialAdUnit.show() needs to be called from relevant delegate event. Check next section.
interstitialAdUnit.loadAd()
}
}
// InterstitialDemoViewController.m file.
#import "InterstitialDemoViewController.h"
@import Nexverse;
@interface InterstitialDemoViewController ()
@property (nonatomic, strong) InterstitialRenderingAdUnit *interstitialAdUnit;
@end
@implementation InterstitialDemoViewController
- (void)loadView {
[super loadView];
[self createAd];
}
- (void)createAd {
// 1. Create a InterstitialRenderingAdUnit
self.interstitialAdUnit = [[InterstitialRenderingAdUnit alloc] initWithConfigID:@"replace-with-actual-config-id"];
// 2. Configure the InterstitialRenderingAdUnit
// For video, use [[NSSet alloc] initWithObjects:AdFormat.video, nil];
// For multiformat, use [[NSSet alloc] initWithObjects:AdFormat.banner, AdFormat.video, nil];
self.interstitialAdUnit.adFormats = [[NSSet alloc] initWithObjects:AdFormat.banner, nil];
self.interstitialAdUnit.delegate = self;
self.interstitialAdUnit.redirectionType = RedirectionTypeExternalBrowser; // defaults to RedirectionTypeInternalBrowser
// Set below properties to determine whether video controls are visibile or not.
self.interstitialAdUnit.isPlaybackButtonVisible = YES;
self.interstitialAdUnit.isMuteButtonVisible = YES;
// 3. Load the interstitial ad
// NOTE: This will just load the ad,
// [interstitialAdUnit show] needs to be called from relevant delegate event. Check next section.
[self.interstitialAdUnit loadAd];
}
@end
Native ads offer the most customizable ad experience, allowing you to match your app’s look and feel perfectly. The SDK provides various classes to load and display native ads that integrate seamlessly with your UI.
Rewarded ads offer users in-app rewards for watching video advertisements. This format typically shows high engagement rates and provides a positive user experience through value exchange.
class RewardedAdDemoViewController: UIViewController {
private var rewardedAdUnit: RewardedAdUnit!
override func loadView() {
super.loadView()
createAd()
}
func createAd() {
// 1. Create a RewardedAdUnit
rewardedAdUnit = RewardedAdUnit(configID: "replace-with-actual-config-id")
// 2. Configure RewardedAdUnit
rewardedAdUnit.delegate = self
rewardedAdUnit.redirectionType = .externalBrowser // defaults to .internalBrowser
// Set below properties to determine whether video controls are visibile or not.
rewardedAdUnit.isPlaybackButtonVisible = true
rewardedAdUnit.isMuteButtonVisible = true
// 3. Load the rewarded ad
// NOTE: This will just load the ad,
// rewardedAdUnit.show() needs to be called from relevant delegate event. Check next section.
rewardedAdUnit.loadAd()
}
}
// RewardedAdDemoViewController.m file.
#import "RewardedAdDemoViewController.h"
@import Nexverse;
@interface RewardedAdDemoViewController ()
@property (nonatomic, strong) RewardedAdUnit * rewardedAdUnit;
@end
@implementation RewardedAdDemoViewController
- (void)loadView {
[super loadView];
[self createAd];
}
- (void)createAd {
// 1. Create a RewardedAdUnit
self.rewardedAdUnit = [[RewardedAdUnit alloc] initWithConfigID:@"replace-with-actual-config-id"];
// 2. Configure RewardedAdUnit
self.rewardedAdUnit.delegate = self;
self.rewardedAdUnit.redirectionType = RedirectionTypeExternalBrowser; // defaults to RedirectionTypeInternalBrowser
// Set below properties to determine whether video controls are visibile or not.
self.rewardedAdUnit.isPlaybackButtonVisible = YES;
self.rewardedAdUnit.isMuteButtonVisible = YES;
// 3. Load the rewarded ad
// NOTE: This will just load the ad,
// [rewardedAdUnit show] needs to be called from relevant delegate event. Check next section.
[self.rewardedAdUnit loadAd];
}
@end