Integrate Vungle SDK for iOS

Use this article to easily integrate the Vungle SDK for iOS, whether you are using Objective-C or Swift.

Before You Begin

Requirements

  • The integration requires a Vungle account, so create a Vungle account if you haven’t already done so, and create a new iOS app in your account. Refer to the Add Your Apps and Placements section of our Using the Publisher Dashboard article to learn how to set up placements in the Vungle dashboard.
  • The Vungle iOS SDK v.6.7.0 supports Xcode 11 or higher as recommended by Apple.
    We recommend using Xcode 11 to archive your app, because archiving with Xcode 10 will result in "invalid Bitcode version error."
  • The Vungle iOS SDK v.6.7.0 has been tested with the latest iOS version (iOS 13.4 as of the release date) and supports 64-bit apps.
  • Vungle iOS SDK v.6.7.0 supports applications that run on iOS 9 and higher. We do not recommend integrating the SDK in iOS versions lower than 9.0.

Download the SDK

Download the Vungle SDK for iOS here: VungleSDK v.6.7.0.

Reference: Sample App and Source Code

Feel free to refer to the sample app we have provided as you integrate: https://github.com/Vungle/iOS-SDK. The source code referenced here is available in our public GitHub repository:

Step 1. Add the Vungle Framework to Your Xcode Project

There are two ways to add Vungle to your Xcode project: using Cocoapods or manual integration.

Option 1. Cocoapods

The Vungle SDK is available through Cocoapods. Add the following into your project’s podfile:

source 'https://github.com/Vungle/ios-sdk-beta.git'
pod "VungleSDK-iOS", "6.7.0"

After that, a quick pod install run will update your project with the latest version of our iOS SDK. At this point you can skip down to Step 2. Remove the iOS Status Bar.

Option 2. Manual Integration

1. Add the VungleSDK.framework to Your Project

Download Vungle SDK v6.7.0. If you are updating from a previous version of the Vungle SDK, first remove the VungleSDK.framework directory completely before adding the new SDK.

Find the extracted files and drag the VungleSDK.framework directory into Xcode under Frameworks. Be sure to add the VungleSDK.framework folder as a group (yellow folder) and not as a reference (blue folder).

2. Add Other Required Frameworks

The Vungle SDK now ships with the build setting Link Frameworks Automatically set to YES; this means that you should no longer be required to link all the previously required frameworks and libraries (see below). With this update, you should only need to optionally link the following frameworks:

  • CoreFoundation.framework
  • Foundation.framework
  • StoreKit.framework

These previously required frameworks and libraries are included here so you can remove them if your project doesn’t reference any of them:

  • Support.framework
  • AudioToolbox.framework
  • AVFoundation.framework
  • CFNetwork.framework
  • CoreGraphics.framework
  • CoreMedia.framework
  • libz.dylib or libz.tbd
  • MediaPlayer.framework
  • QuartzCore.framework
  • StoreKit.framework
  • SystemConfiguration.framework

Note: Vungle SDK v.6.5.1+ does not support iOS 8 or lower. If you have iOS 7 as a deployment target, use Vungle iOS SDK v.4.1 or lower, and include these frameworks:

  • UIKit.framework
  • WebKit.framework
  • Foundation.framework

Confirm that the VungleSDK framework appears under Linked Frameworks and Libraries.

3. Add the “-ObjC” Linker Flag

Click on your project in Project Navigator and go to Build Settings → Linking → Other Linker Flags. Add -ObjC to Other Linker Flags.

Step 2. Remove the iOS Status Bar

Although this step is not required, we recommend that you remove the iOS status bar to ensure that Vungle's ad interaction and presentation perform smoothly. To remove the status bar, open your Info.plist, add the key View controller-based status bar appearance, and set it to No.

Step 3. Add Code

Swift Only: Create a Bridging Header File

  1. Create a new Objective-C file in your project (File  New  File [Objective-C File]).
  2. When Xcode asks if you want to create a bridging header file between Objective-C and Swift, accept the prompt.
  3. Delete the new Objective-C file (${YOURPROJ}-Bridging-Header.m), but retain the bridging header file ${YOURPROJ}-Bridging-Header.h.
  4. In the Bridging header file, import the Vungle SDK by adding the following:
    #import <VungleSDK/VungleSDK.h>
    

Initialize the SDK

Initialize the SDK as soon as your app starts. If you are using a cache-optimized placement, initializing now gives the SDK enough time to cache an ad for that placement. You will need the App ID to initialize the SDK. You can find the App ID in the Vungle Dashboard.

- (BOOL)startWithAppId:(nonnull NSString *)appID error:(NSError **)error;

Sample code:

Objective-CSwift
#import <VungleSDK/VungleSDK.h> 
... 
NSError* error; 
NSString* appID = @"Your_AppID_Here"; 
VungleSDK* sdk = [VungleSDK sharedSDK]; 
if (![sdk startWithAppId:appID error:&error]) { 
  if (error) { 
    NSLog(@"Error encountered starting the VungleSDK: %@", error); 
  } 
}

Once the SDK is initialized successfully, the following callback method is called:

- (void)vungleSDKDidInitialize;

Refer to the Receive Delegate Callbacks section of this article.

You can also check the status of the SDK initialization with the following property:

@property (atomic, readonly, getter=isInitialized) BOOL initialized;

Starting with Vungle SDK v.6.4.3, after initialization we automatically optimize the caching behaviors to maximize your monetization.

Once initialization is successful, watch for the vungleAdPlayabilityUpdate callback method to be called with the placement reference IDs matching your cache-optimized placement. (Refer to the Check Ad Availability for a Placement section.)

Load an Ad for a Placement

To load an ad, call the loadPlacementWithID method:

- (BOOL)loadPlacementWithID:(NSString *)placementID error:(NSError **)error;

Sample code:

Objective-CSwift
NSError* error;
VungleSDK* sdk = [VungleSDK sharedSDK];
NSString* placementID = @"Your_placement_ID_Here";
VungleSDK* sdk = [VungleSDK sharedSDK];
if (![sdk loadPlacementWithID:placementID error:&error]) {
if (error) {
NSLog(@"Error occurred when loading placement: %@", error);
}
}

Check Ad Availability for a Placement

Once the SDK finishes caching an ad for a placement, the following callback method is called:

- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID error:(nullable NSError *)error;

Sample code:

Objective-CSwift
- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(NSString *)placementID error:(nullable NSError *)error {
    if([placementID isEqualToString:@"Your_placement_ID_Here"]) {
        self.playButtonPlacement1.enabled = isAdPlayable;
    }
}

Note: For the cache-optimized placements, this callback method is called only when an ad becomes available. The SDK will keep requesting an ad for these placements. For all other placements, this callback method is called in case of “Load Failed” (isAdPlayable returns ‘NO’ in this case).

You can also check the ad availability for a placement with the following property:

- (BOOL)isAdCachedForPlacementID:(nonnull NSString *)placementID;

Play an Ad

After you make sure that an ad is ready for a placement, you can play the ad with the following method:

- (BOOL)playAd:(UIViewController *)controller options:(nullable NSDictionary *)options placementID:(nullable NSString *)placementID error:( NSError *__autoreleasing _Nullable *_Nullable)error;

Sample code:

Objective-CSwift
VungleSDK* sdk = [VungleSDK sharedSDK];
NSError *error;
if (![sdk playAd:self options:nil placementID:@"Your_placement_ID_Here" error:&error]) {
if (error) {
NSLog(@"Error encountered playing ad: %@", error);
}
}

Optional and Advanced Settings

Integrate MREC Ads

Vungle Banner is currently in BETA phase. Please contact your account manager directly for access to ensure a successful launch.

Starting with Vungle SDK v.6.4.3, we support MREC ads. This ad format does not require a full screen; instead, the publisher determines the location of the ad container within their app. However, the size of the MREC container has to be 300 × 250, which is the industry standard.

Load an MREC Ad

The placement type for MREC has to have the type MREC in Vungle dashboard.

Display an MREC Ad

You must first create a container for the MREC ads. This container is a UIView with the size of 300 × 250. You can place this UIView anywhere on the screen. You must then call the addAdViewToView function to associate the container with the MREC ad.

Function overview:

/**
* Pass in an UIView which acts as a container for the ad experience. This view container may be placed in random positions.
* @param publisherView container view in which an ad will be displayed
* @param options A reference to an instance of NSDictionary with customized ad playback options
* @param placementID The placement defined on the Vungle dashboard
* @param error An optional double reference to an NSError. In case this method returns `NO` it will be non-nil
* @return YES/NO in case of success/error while presenting an AdUnit
*/
- (BOOL)addAdViewToView:(UIView *)publisherView withOptions:(nullable NSDictionary *)options placementID:(nullable NSString *)placementID error:( NSError *__autoreleasing _Nullable *_Nullable)error;

Sample code:

NSError *error;
NSDictionary *options = @{};
VungleSDK* sdk = [VungleSDK sharedSDK];
if (![sdk addAdViewToView:_mrecViewArea withOptions:options placementID:@"Your_placement_ID_Here" error:&error]) {
if (error)
{
NSLog(@"Error encountered while playing an ad: %@", error);
}
}

Close an MREC Ad

To close an MREC ad, call the finishedDisplayingAd function. This function only works with MREC ads. Note that this function does not take in a placement; it will simply close any MREC ad currently playing. Depending on the implementation, you may need to include some cleanup (such as removing the MREC container UIView from its parent view, etc).

Function overview:

As of 6.7.0Deprecated
- (void)finishDisplayingAd:(NSString *)placementId;

Sample code:

//Ad is no longer on screen
VungleSDK* sdk = [VungleSDK sharedSDK];
[sdk finishedDisplayingAd:@"MREC_PLACEMENTID_HERE"];

Integrate Banner Ads

Vungle Banner is currently in BETA phase. Please contact your account manager directly for access to ensure a successful launch.

Starting with Vungle SDK v.6.5.1, we support banner ads. This ad format does not require a full screen; instead, the publisher determines the location of the ad container within their app. However, the size of the banner container must be either 320x50, 300x50, or 728x90 (for tablets). You can set banner ads anywhere on the screen, and the user can continue using the app while the ad is being played. The Enum listing the different banner sizes can be found in the VungleSDK.h file (also described in the table below).

Banner Sizes Dimension
VungleAdSizeBanner 320 x 50
VungleAdSizeBannerShort 300 x 50
VungleAdSizeBannerLeaderboard 728 x 90

The placement type for banner ads must have the type "Banner" in the Vungle dashboard. Feel free to contact your account manager to enable banner placement on the dashboard.

Load a Banner Ad

Loading a banner ad works differently from other ad formats. Use the following API to load the banner ad. You must specify size of the banner that you want to load and the SDK automatically refreshes the banner following the time interval that you configured on the dashboard. Refer the above table for enum values that required by the load call.

Function overview:

/**
 * (Overloaded method)
 * Prepares a placement when you know that you will want
 * to show an ad experience tied to a specific placementID.
 * @param placementID the specific ID of the placement you would like to present at some point soon
 * @param size the VungleAdSize (enum) you would like to request (only for banner ad type at the moment)
 * @return NO if something goes immediately wrong with loading, YES otherwise
 */
- (BOOL)loadPlacementWithID:(NSString *)placementID withSize:(VungleAdSize)size error:(NSError **)error;

Sample code:

NSError* error;
VungleSDK* sdk = [VungleSDK sharedSDK];
if (![sdk loadPlacementWithID:@"Your_placement_ID_Here" withSize:BANNER_ENUM error:&error]) {
if (error) {
NSLog(@"Error occurred when loading placement: %@", error);
}
}

You can also check for the banner ad availability by calling the following API:

Function overview:

/**
* (Overloaded method)
 * Returns `YES` when there is certainty that an ad will be able to play for a given placementID.
 * Returning `NO`.
 * @param size the VungleAdSize (enum) you would like to request (only for banner ad type at the moment)
 * @param placementID the specific ID of the placement you are trying to present
 */
- (BOOL)isAdCachedForPlacementID:(nonnull NSString *)placementID withSize:(VungleAdSize)size;

Sample code:

if([sdk isAdCachedForPlacementID:@"Your_placement_ID_Here" withSize:BANNER_ENUM]){
//Ad is cached successfully
}

Display a Banner Ad

You must first create a container for the banner ads. This container is a UIView with the size of either 300×250 , 320x50, or 728x90 (for iPads only). You can place this UIView anywhere on the screen.
You must then call the addAdViewToView function to associate the container with the banner ad.

Function overview:

/**
 * Pass in an UIView which acts as a container for the ad experience. This view container may be placed in random positions.
 * @note This method should only be called using placements that have the `mrec` template type. ALSO, for the
 *`mrec` template type, note that the UIView must have a width of 300 and a height of 250. If the view is provided without
 * these dimensions, an error message will be returned and the ad will not be shown.
 * @param publisherView container view in which an ad will be displayed
 * @param options A reference to an instance of NSDictionary with customized ad playback options
 * @param placementID The placement defined on the Vungle dashboard
 * @param error An optional double reference to an NSError. In case this method returns `NO` it will be non-nil
 * @return YES/NO in case of success/error while presenting an AdUnit
 */
- (BOOL)addAdViewToView:(UIView *)publisherView withOptions:(nullable NSDictionary *)options placementID:(nullable NSString *)placementID error:(NSError *__autoreleasing _Nullable *_Nullable)error;

Sample code:

NSError *error;
NSDictionary *options = @{};
VungleSDK* sdk = [VungleSDK sharedSDK];
if (![sdk addAdViewToView:_bannerViewArea withOptions:options placementID:@"Your_placement_ID_Here" error:&error]) {
if (error)
{
NSLog(@"Error encountered while playing an ad: %@", error);
}
}

Close a Banner Ad

Call the finishedDisplayingAd function to close the banner ad. Note that this function does not take in a placement; it will simply close any banner ad currently playing. Depending on your implementation, you may need to include some cleanup (such as removing the banner container UIView from its parent view, etc).

Function overview:

As of 6.7.0Deprecated
- (void)finishDisplayingAd:(NSString*)placementId;

Sample code:

VungleSDK* sdk = [VungleSDK sharedSDK];
[sdk finishedDisplayingAd:@"BANNER_PLACEMENTID_HERE"];

Receive Delegate Callbacks

You can receive callbacks from the SDK with VungleSDKDelegate. The callback methods in the delegate notify the app about SDK events.

You can attach and detach your delegate with the following:

Objective-CSwift
// Attach
[[VungleSDK sharedSDK] setDelegate:yourDelegateInstance];
// Detach
[[VungleSDK sharedSDK] setDelegate:nil];

Note: To avoid memory leaks, remember to clear the registered delegate when it's no longer needed.

The following method is called when the SDK has initialized successfully:

- (void)vungleSDKDidInitialize;

The following method is called when the SDK is about to play a video ad. This is a great place to pause gameplay, sound effects, animations, etc.

- (void)vungleWillShowAdForPlacementID:(nullable NSString *)placementID;

The following method is called when the SDK has just begun to play a video ad:

- (void)vungleDidShowAdForPlacementID:(nullable NSString *)placementID;

The following method is called when the SDK is about to close an ad. This is a great place to reward your user and resume gameplay, sound effects, animations, etc.

As of 6.7.0Deprecated
- (void)vungleWillCloseAdForPlacementID:(nonnull NSString *)placementID;

The following method is called when the SDK has closed an ad.

As of 6.7.0Deprecated
- (void)vungleDidCloseAdForPlacementID:(nonnull NSString *)placementID;

The following method is called when the SDK has changed ad availability status. The isAdPlayable Boolean denotes the new playability of a specific placementID. (Refer to the Check Ad Availability for a Placement section.)

- (void)vungleAdPlayabilityUpdate:(BOOL)isAdPlayable placementID:(nullable NSString *)placementID error:(nullable NSError *)error;

The following method is called when the user clicks the Vungle ad. At this point, it is recommended to track click event.

- (void)vungleTrackClickForPlacementID:(nullable NSString *)placementID;

The following method is called when the user taps the Vungle ad which will cause them to leave the current application (e.g the ad action opens the iTunes store, Mobile Safari, etc).

- (void)vungleWillLeaveApplicationForPlacementID:(nullable NSString *)placementID;

 

The following method is called when the user should be rewarded for watching a Rewarded Video ad. At this point, it's recommended to reward the user.

- (void)vungleRewardUserForPlacementID:(nullable NSString *)placementID;

The following method is called when the SDK fails to initialize. If this happens, restart the Vungle SDK.

- (void)vungleSDKFailedToInitializeWithError:(NSError *)error;

Deprecated as of 6.7.0

VungleViewInfo includes the following properties for you to check a result of ad play:

Deprecated
/**
Deprecated as of 6.7.0
**/
@interface VungleViewInfo : NSObject
//Represents a BOOL whether or not the video can be considered a completed view.
@property (nonatomic, readonly) NSNumber *completedView;
//The time in seconds that the user watched the video.
@property (nonatomic, readonly) NSNumber *playTime;
//Represents a BOOL whether or not the user clicked the download button.
@property (nonatomic, readonly) NSNumber *didDownload;
@end

Ad Configuration Options

Use these options to customize the ad experience for playback.

Note: Rewarded ads are in some cases referred to as incentivized ads; both terms always refer to the same kind of ad. In the SDK code and in our Reporting API, we use the term 'incentivized'.

Option Keys Default Value / Type Description
VunglePlayAdOptionKeyOrientations autorotate
UIInterfaceOrientationMaskAll
An NSNumber representing a bitmask with orientations
Sets the orientation of the ad. We recommend allowing ads to autorotate, even if your app is in portrait. This way, the user has the option to watch full-size videos, resulting in a better user experience. You can achieve this by setting the orientation at the view controller level (rather than at the project level).
VunglePlayAdOptionKeyUser nil
NSString
Sets your user ID. The value is passed to the Vungle server, and then sent to your server through a server-to-server callback system if a placement is set to “Rewarded”.
VunglePlayAdOptionKeyIncentivizedAlertTitleText nil
NSString
String used for the title of the alert dialog that displays when a user prematurely closes a rewarded ad experience.
VunglePlayAdOptionKeyIncentivizedAlertBodyText “Are you sure you want to skip this ad? If you do, you might not get your reward”
NSString
String used for the body text of the alert dialog that displays when a user prematurely closes a rewarded ad experience.
VunglePlayAdOptionKeyIncentivizedAlertCloseButtonText “Close”
NSString
String title for the close button text of the alert dialog that displays when a user prematurely closes a rewarded ad experience.
VunglePlayAdOptionKeyIncentivizedAlertContinueButtonText “Continue”
NSString
String title for the close button text of the alert dialog that displays when a user prematurely closes a rewarded ad experience.
VunglePlayAdOptionKeyOrdinal Int If you receive ordinal data reports from Vungle, use this field to pass the mediation ordinal. This is an integer indicating the order in which this ad was shown in the game session (for example, if two ads were already shown in this session, and this ad from Vungle was then shown third, pass in '3'). Read more about ordinal data here.

Sample code:

Objective-CSwift
NSDictionary *options = @{VunglePlayAdOptionKeyOrientations: @(UIInterfaceOrientationMaskLandscape),
                          VunglePlayAdOptionKeyUser: @"userGameID",
                          VunglePlayAdOptionKeyIncentivizedAlertBodyText : @"If the video isn't completed you won't get your reward! Are you sure you want to close early?",
                          VunglePlayAdOptionKeyIncentivizedAlertCloseButtonText : @"Close",
                          VunglePlayAdOptionKeyIncentivizedAlertContinueButtonText : @"Keep Watching",
                          VunglePlayAdOptionKeyIncentivizedAlertTitleText : @"Careful!"};

// Pass in dict of options, play ad
NSError *error;
[self.sdk playAd:self options:options placementID: error:&error];

if (error) {
    NSLog(@"Error encountered playing ad: %@", error);
}

Mute Option

The Vungle SDK instance offers the option to play ads with the sound disabled. You can set the muted property to 'true' before issuing a playAd().

Sample code:

Objective-CSwift
VungleSDK* sdk = [VungleSDK sharedSDK];
self.sdk.muted = true;

Note: This option only applies to the standard ad type for Vungle SDK version 6.3.1 and lower. The muted option for Dynamic Template ads is available to configure on the dashboard. Starting with Vungle SDK v6.3.2, Vungle will respect the SDK-side mute setting for all ads.

Memory Settings

Starting with Vungle SDK v6.4.3, you can prevent the SDK from downloading, requesting ads, or even initializing, if the storage of your iPhone falls below a predefined threshold. If this happens, you will get an error similar to the following:

Error while starting VungleSDK There is not enough file system size on a device to initialize VungleSDK.

These are the option keys available:

Option Keys

Default Value / Type

Description

vungleMinimumFileSystemSizeForInit

Integer, value in MB, default value is 50

Sets the required minimum available free storage space to allow the SDK to initialize

vungleMinimumFileSystemSizeForAdRequest

Integer, value in MB, default value is 50

Sets the required minimum available free storage space to enable you to request an ad

Sample code:

[[NSUserDefaults standardUserDefaults] setInteger:200 forKey:@"vungleMinimumFileSystemSizeForInit"];
[[NSUserDefaults standardUserDefaults] setInteger:200 forKey:@"vungleMinimumFileSystemSizeForAdRequest"];
//After setting the desired values above, synchronize
[[NSUserDefaults standardUserDefaults] synchronize];

Restrict Use of IDFV

Starting with Vungle SDK v6.4.3, you can prevent passing the IDFV from the device to the SDK.

Sample code:

[VungleSDK setPublishIDFV:NO];
if (![sdk startWithAppId:appID error:&error]) {
  if (error) {
    NSLog(@"Error encountered starting the VungleSDK: %@", error);
  }
}

CCPA Recommended Implementation Instructions

As of July 1, 2020, California Consumer Privacy Act (CCPA) will be enforced and publishers must updated to iOS SDK 6.7.0 to comply with CCPA The [VungleSDK updateCCPAStatus] method takes the user’s CCPA consent status to notify us when a user has OPTED_OUT .  Additionally, [VungleSDK getCCPAStatus] method returns current CCPA status for the user.

Objective-C
//OPT_IN
[self.sdk updateCCPAStatus:VungleCCPAAccepted];
//OPT_OUT
[self.sdk updateCCPAStatus:VungleCCPADenied];

GDPR Recommended Implementation Instructions

As of May 25, 2019, the General Data Protection Regulation (GDPR) will be enforced in the European Union. To comply with GDPR, developers have two options.

  • Option 1 (recommended): Publisher controls the GDPR consent process at the user level, then communicates the user’s choice to Vungle. To do this, developers can collect the user’s consent using their own mechanism, and then use Vungle APIs to update or query the user’s consent status. Refer to the sample code below for details.
  • Option 2: Allow Vungle to handle the requirements. Vungle will display a consent dialog before playing an ad for a European user, and will remember the user’s consent or rejection for subsequent ads.

To use Vungle APIs to update or query the user’s consent status (as recommended in Option 1), use these functions for Vungle SDK v6.3.2 and higher:

Objective-CSwift
// This function sets the consent status that will be recorded in Vungle SDK. Accepted values: 'VungleConsentAccepted' or 'VungleConsentDenied'. It also sets the consent message version. This value is an arbitrary string, and can be used to identify the version of the consent message presented to the user.

// To set the user's consent status to opted in:
[[VungleSDK sharedSDK] updateConsentStatus:VungleConsentAccepted consentMessageVersion:@"Some Consent Message Version"];

// To set the user's consent status to opted out:
[[VungleSDK sharedSDK] updateConsentStatus:VungleConsentDenied consentMessageVersion:@"Some Consent Message Version"];

// To find out what the user's current consent status is: 
// (Check against enum values: 'VungleConsentAccepted' or 'VungleConsentDenied'.)

[[VungleSDK sharedSDK] getCurrentConsentStatus];

// To find out which version of the consent message was shown to the user:
// This method returns an NSString value.
[[VungleSDK sharedSDK] getConsentMessageVersion];

VungleConsentStatus is an enum with two states:

  • VungleConsentAccepted
  • VungleConsentDenied

The SDK also has an initial state of 'unknown', which prompts the user to opt in or opt out of user data collection. Note that this prompt only occurs on IP addresses originating from Europe.

Because Vungle SDK v6.2.0 cannot pass the consent message version, use the following APIs:

// This function sets the consent status that will be recorded in Vungle SDK. Accepted values: 'VungleConsentAccepted' or 'VungleConsentDenied'.
// To set the user's consent status to opted in:
[[VungleSDK sharedSDK] updateConsentStatus:VungleConsentAccepted]

// To set the user's consent status to opted out:
[[VungleSDK sharedSDK] updateConsentStatus:VungleConsentDenied];

// To find out what the user's current consent status is:
// (Check against enum values: 'VungleConsentAccepted' or 'VungleConsentDenied'.)
[[VungleSDK sharedSDK] getCurrentConsentStatus];

Debug

Use this property to get SDK information:

- (NSDictionary *)debugInfo;

Use the following method for the SDK to output logs:

- (void)setLoggingEnabled:(BOOL)enable;

VungleSDKLogger Protocol

@protocol VungleSDKLogger 
- (void)vungleSDKLog:(NSString*)message;
@end

The VungleSDK singleton sends logging events to any attached class following the VungleSDKLogger protocol. The log event contains the NSString value that is also printed to console (if logging has been enabled). To attach your logger, use the following:

Objective-CSwift
[[VungleSDK sharedSDK] attachLogger:yourLoggerInstance];

As we stated above, it's important to clear out attached loggers from the Vungle SDK. To detach your logger, use the following:

Objective-CSwift
[[VungleSDK sharedSDK] detachLogger:yourLoggerInstance];

Check the Initialization State

Some of the resources allocated to the Vungle SDK can be terminated by the OS if system resources are running low or if too much context switching is occurring. To ensure smooth operation of SDK, we recommend checking the SDK initialization state before invoking the SDK API. Invoke isInitialized before calling any SDK API and reinitialize the SDK if isInitialized returns NO.

if ([self.sdk isInitialized] == NO) {
   [self initVungleSDK];
}
Powered by Creativity Driven by Performance Sign Up Here

Questions?

Need further assistance, feel free to reach out to us, we’re here to help!

Was this article helpful?