Unity LevelPlay
This guide shows you how to integrate our BlueStack mediation adapter of Unity LevelPlay with your current iOS app and set up additional request parameters.
Release notes can be found here
Supported ad formats
- Banner
- Rewarded
- Interstitial
Requirements
- Xcode 14.0 or higher
- iOS: 12.2 or higher
Unity LevelPlay Configuration
When in the Unity LevelPlay dashboard, under your app in the left panel navigate to Setup -> Networks, in the right panel at the bottom of the page you have the option to Add custom network.
You'll be directe to a new page.
Please enter 15c080481 in the Network Key input field and click Confirm Key. After confirmation it will show the network name Improve Digital. Then click Save.
Custom Network Key: 15c080481
Custom Network Name: Improve Digital
Congratulations!!! You have added our network successfully.
Next navigate to Setup -> Instances in the left panel, and click Improve Digital in the right panel.
This will navigate you to a new page where you will add new instances for different types of ads.
Click on the button **+ Add Instance at the bottom in the right panel, select the type of ad you want to add.
Enter Instance Name, placementId, Rate, and select target Mediation Groups. Also add your appId at the top in the right panel and click Save.
Note: The placementIds will be provided by the Azerion team. And Rate is used for IronSource reporting only, it will not be a reflection of the actual money. Rates can be aligned with the Azerion team as well.
Integrate BlueStackLevelPlayMediationAdapter in your application project
- CocoaPods
- Swift Package Manager
In the Podfile
of your application project add BlueStackLevelPlayMediationAdapter
dependency
pod 'BlueStackLevelPlayMediationAdapter', '5.1.1.0'
Go to your project file --> Package Dependencies --> Add(+) --> Search for https://github.com/azerion/BlueStack-LevelPlay-Mediation.git
Import custom event classes in your source file:
- Objective C
- Swift
@import BlueStackLevelPlayMediationAdapter;
@import IronSource;
import BlueStackLevelPlayMediationAdapter
import IronSource
Ad Formats
Banner
Supported ISBannerAdDelegate Callback
- Objective C
- Swift
// Indicates that a banner ad was loaded successfully
- (void)adDidLoadWithView:(UIView *) view
// The banner ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
- (void)adDidFailToLoadWithErrorType:(ISAdapterErrorType)errorType
errorCode:(NSInteger)errorCode
errorMessage:(nullable NSString*)errorMessage
// Indicates an ad was clicked
- (void)adDidClick
// Indicates that a banner ad was loaded successfully
func adDidLoad(_ bannerView: UIView) { }
// The banner ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
func adDidFailToLoadWith(_ errorType: ISAdapterErrorType, errorCode: Int, errorMessage: String!) { }
// Indicates an ad was clicked
func adDidClick() { }
Initialization and load Banner Ad
- Objective C
- Swift
self.adView = [[LPMBannerAdView alloc] initWithAdUnitId:@"YOUR_BANNER_AD_UNIT_ID"];
// 1. recommended - Adaptive ad size that adjusts to the screen width
self.bannerSize = [LPMAdSize createAdaptiveAdSize];
// 2. Adaptive ad size using fixed width ad size
// self.bannerSize = [LPMAdSize createAdaptiveAdSizeWithWidth:400];
// 3. Specific banner size - BANNER, LARGE, MEDIUM_RECTANGLE
// self.bannerSize = [LPMAdSize mediumRectangleSize];
[self.adView setAdSize:self.bannerSize];
[self.bannerAd loadAdWithViewController:YOUR_VIEW_CONTROLLER_INSTANCE];
let adView = LPMBannerAdView(adUnitId: "YOUR_BANNER_AD_UNIT_ID")
// 1. recommended - Adaptive ad size that adjusts to the screen width
bannerSize = LPMAdSize.createAdaptive()
// 2. Adaptive ad size using fixed width ad size
// bannerSize = LPMAdSize.createAdaptiveAdSize(withWidth: 400)
// 3. Specific banner size - BANNER, LARGE, MEDIUM_RECTANGLE
// bannerSize = LPMAdSize.mediumRectangle()
adView.setAdSize(bannerSize)
adView.loadAd(with: YOUR_VIEW_CONTROLLER_INSTANCE)
Interstitial
Supported ISInterstitialAdDelegate Callback
- Objective C
- Swift
// Indicates that the interstitial ad was loaded successfully
- (void)adDidLoad;
// The interstitial ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
- (void)adDidFailToLoadWithErrorType:(ISAdapterErrorType)errorType
errorCode:(NSInteger)errorCode
errorMessage:(NSString*)errorMessage;
// The interstitial ad was displayed successfully to the user. This indicates an impression.
- (void)adDidOpen;
// User closed the interstitial ad
- (void)adDidClose;
// The ad could not be displayed
- (void)adDidFailToShowWithErrorCode:(NSInteger)errorCode
errorMessage:(NSString*)errorMessage;
// Indicates the ad was clicked
- (void)adDidClick;
// Indicates that the interstitial ad was loaded successfully
func adDidLoad() { }
// The interstitial ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
func adDidFailToLoadWith(_ errorType: ISAdapterErrorType, errorCode: Int, errorMessage: String!) { }
// The interstitial ad was displayed successfully to the user. This indicates an impression.
func adDidOpen() { }
// User closed the interstitial ad
func adDidClose() { }
// The ad could not be displayed
func adDidFailToShowWithErrorCode(_ errorCode: Int, errorMessage: String!) { }
// Indicates the ad was clicked
func adDidClick() { }
Initialization, load, and show Interstitial Ad
- Objective C
- Swift
self.interstitialAd = [[LPMInterstitialAd alloc] initWithAdUnitId:@"YOUR_INTERSTITIAL_AD_UNIT_ID"];
[self.interstitialAd loadAd];
if ([self.interstitialAd isAdReady]) {
// This will present the Interstitial.
// Unlike Rewarded Videos there are no placements.
[self.interstitialAd showAdWithViewController:YOUR_VIEW_CONTROLLER placementName:NULL];
}
let interstitialAd = LPMInterstitialAd(adUnitId: "YOUR_INTERSTITIAL_AD_UNIT_ID")
interstitialAd.loadAd()
if (interstitialAd != nil && self.interstitialAd.isAdReady()) {
// This will present the Interstitial.
// Unlike Rewarded Videos there are no placements.
interstitialAd.showAd(viewController: YOUR_VIEW_CONTROLLER, placementName: nil)
}
Rewarded
Supported ISRewardedVideoAdDelegate Callback
- Objective C
- Swift
// Indicates that rewarded video ad was loaded successfully
- (void)adDidLoad;
// The rewarded video ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
- (void)adDidFailToLoadWithErrorType:(ISAdapterErrorType)errorType
errorCode:(NSInteger)errorCode
errorMessage:(NSString*)errorMessage;
// The rewarded video ad was displayed successfully to the user. This indicates an impression.
- (void)adDidOpen;
// User closed the rewarded video ad
- (void)adDidClose;
// The ad could not be displayed
- (void)adDidFailToShowWithErrorCode:(NSInteger)errorCode
errorMessage:(NSString*)errorMessage;
// User clicked the rewarded video ad
- (void)adDidClick;
// User received a reward after watching the ad
- (void)adRewarded;
// Indicates that rewarded video ad was loaded successfully
func adDidLoad() { }
// The rewarded video ad failed to load. Use ironSource ErrorTypes (No Fill / Other)
func adDidFailToLoadWith(_ errorType: ISAdapterErrorType, errorCode: Int, errorMessage: String!) { }
// The rewarded video ad was displayed successfully to the user. This indicates an impression.
func adDidOpen() { }
// User closed the rewarded video ad
func adDidClose() { }
// The ad could not be displayed
func adDidFailToShowWithErrorCode(_ errorCode: Int, errorMessage: String!) { }
// User clicked the rewarded video ad
func adDidClick() { }
// User received a reward after watching the ad
func adRewarded() { }
Initialization, load, and show Rewarded Ad
- Objective C
- Swift
LPMInitRequestBuilder *requestBuilder = [[LPMInitRequestBuilder alloc] initWithAppKey:kAppKey];
[requestBuilder withLegacyAdFormats:@[IS_REWARDED_VIDEO]];
LPMInitRequest *initRequest = [requestBuilder build];
[LevelPlay initWithRequest:initRequest completion:^(LPMConfiguration *_Nullable config, NSError *_Nullable error){
if(error) {
// There was an error on initialization. Take necessary actions or retry
return;
}
// Initialization was successful. You can now load banner ad or perform other tasks
}];
if ([IronSource hasRewardedVideo]) {
// This will present the Rewarded Video.
[IronSource showRewardedVideoWithViewController:self];
}
let requestBuilder = LPMInitRequestBuilder(appKey: YOUR_LEVEL_PLAY_APP_KEY)
.withLegacyAdFormats([IS_REWARDED_VIDEO])
let initRequest = requestBuilder.build()
LevelPlay.initWith(initRequest)
if IronSource.hasRewardedVideo() {
// This will present the Rewarded Video.
IronSource.showRewardedVideo(with: self)
}
Set Privacy Settings
Change the privacy settings accordingly. By default both are false. Please note that you have to set them before initializing the Iron Source/LevelPlay SDK.
- Objective C
- Swift
[BlueStackPrivacySettings setIsAgeRestrictedUser:YES];
[BlueStackPrivacySettings setUserOptout:YES];
BlueStackPrivacySettings.setIsAgeRestrictedUser(true)
BlueStackPrivacySettings.setUserOptout(true)
Passing data for user targeting
- Objective C
- Swift
ISConfigurations *isConfigurations = [ISConfigurations getConfigurations];
isConfigurations.userAge = USERS_AGE;
isConfigurations.userGender = USERS_AGE;
isConfigurations.customSegmentParams = @{@"bs_latitude": USERS_LATITUDE, @"bs_longitude": USERS_LONGITUDE, @"bs_consent_flag": LOCATION_CONSENT_FLAG};
let isConfigurations = ISConfigurations.getConfigurations()
isConfigurations?.userAge = USERS_AGE
isConfigurations?.userGender = USERS_GENDER
isConfigurations?.customSegmentParams = [
BSLevelPlayAudienceTargetingKey.Latitude: USERS_LATITUDE,
BSLevelPlayAudienceTargetingKey.Longitude: USERS_LONGITUDE,
BSLevelPlayAudienceTargetingKey.ConsentFlag: LOCATION_CONSENT_FLAG
]
Meaning of LOCATION_CONSENT_FLAG
- 0 = Not allow to send location.
- 1 = When you managed location according to consent value.
- 2 and 3 = Allow the SDK to managed location directly in accordance with the consent value use TCF v1 or TCF v2, see with the madvertise team it depends on your implementation.