iOS Migration Guide — BlueStack SDK v5 to v6
This guide covers the breaking changes introduced in BlueStack SDK v6.0.0 for iOS and explains how to update your existing v5 integration.
Overview
BlueStack SDK v6 introduces an update that removes the
BlueStack and MNG prefixes from all public API classes
and constants. The underlying functionality remains the same —
only the names have changed. This makes the SDK more neutral
and easier to integrate across different publishing environments.
SDK Initialization
The main entry point for initializing the SDK has been
renamed from BlueStack to MobileAds.
Before (v5)
- Objective C
- Swift
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[BlueStack sharedInstance] initializeWithAppID:@"YOUR_APP_ID_HERE" completion:^(InitializationStatus * _Nonnull initializationStatus) {
}];
return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
BlueStack.sharedInstance().initialize(appID: "YOUR_APP_ID_HERE") { initializationStatus in
}
return true
}
After (v6)
- Objective C
- Swift
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[BLSMobileAds sharedInstance] initializeWithAppID:@"YOUR_APP_ID_HERE" completion:^(InitializationStatus * _Nonnull initializationStatus) {
}];
return YES;
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
MobileAds.sharedInstance().initialize(appID: "YOUR_APP_ID_HERE") { initializationStatus in
}
return true
}
Privacy Settings
The privacy settings class has been renamed
from BlueStackPrivacySettings to PrivacySettings.
Before (v5)
- Objective C
- Swift
[BlueStackPrivacySettings setIsAgeRestrictedUser:YES];
[BlueStackPrivacySettings setUserOptout:YES];
BlueStackPrivacySettings.setIsAgeRestrictedUser(true)
BlueStackPrivacySettings.setUserOptout(true)
After (v6)
- Objective C
- Swift
[PrivacySettings setIsAgeRestrictedUser:YES];
[PrivacySettings setUserOptout:YES];
PrivacySettings.setIsAgeRestrictedUser(true)
PrivacySettings.setUserOptout(true)
Error Handling
Error classes and constants have been renamed
to remove the BlueStack prefix.
| v5 | v6 |
|---|---|
BlueStackError | AdError |
BlueStackErrorCode | AdErrorCode |
Error Constants
All error constants have been renamed
from the BlueStack* prefix to the AdError* prefix:
| v5 Constant | v6 Constant |
|---|---|
BlueStackErrorWrongPlacement | AdErrorWrongPlacement |
BlueStackErrorAdServer | AdErrorAdServer |
BlueStackErrorDataAdServer | AdErrorDataAdServer |
BlueStackErrorSDKUninitialized | AdErrorSDKUninitialized |
BlueStackErrorCappedRequest | AdErrorCappedRequest |
BlueStackErrorLockedPlacement | AdErrorLockedPlacement |
BlueStackErrorBusyFactory | AdErrorBusyFactory |
BlueStackErrorBusy | AdErrorBusy |
BlueStackErrorUnallowedBackgroundRequest | AdErrorUnallowedBackgroundRequest |
BlueStackErrorNoAds | AdErrorNoAds |
MAdvertiseErrorInterstitialCooldown | AdErrorInterstitialCooldown |
BlueStackErrorAlreadyShownInterstitial | AdErrorAlreadyShownInterstitial |
BlueStackErrorRequestTimedOut | AdErrorRequestTimedOut |
BlueStackErrorMissingViewController | AdErrorMissingViewController |
BlueStackErrorUnableToDisplayAd | AdErrorUnableToDisplayAd |
BlueStackErrorAdExpired | AdErrorAdExpired |
New Error Codes in v6
The following error codes are new in v6 and do not have v5 equivalents:
| Constant | Description |
|---|---|
AdErrorNoInternet | No internet connection available. |
AdErrorAlreadyShownAppOpen | An app open ad is already being displayed. |
AdErrorNoAdapterFoundForPlacement | No mediation adapter found for the placement. |
AdErrorAdapterClassNotFound | The adapter class could not be found. |
AdErrorInternal | An unexpected internal error occurred. |
Before (v5)
- Objective C
- Swift
- (void)bannerView:(BannerView * _Nonnull)bannerView didFailedToLoadWithError:(NSError * _Nonnull)error {
switch (error.code) {
case BlueStackErrorWrongPlacement:
NSLog(@"Wrong placement Id. %@", error.localizedDescription);
break;
case BlueStackErrorSDKUninitialized:
NSLog(@"BlueStackSDK is not initialized. %@", error.localizedDescription);
break;
default:
NSLog(@"Unhandled error");
break;
}
}
func onFailedToLoad(_ bannerView: BlueStackSDK.BannerView, _ error: any Error) {
guard let error = error as? BlueStackError, let errorCode = BlueStackErrorCode(rawValue: error.code) else { return }
switch errorCode {
case .BlueStackErrorWrongPlacement:
print("Wrong placement Id. \(error.localizedDescription)")
case .BlueStackErrorSDKUninitialized:
print("BlueStackSDK is not initialized. \(error.localizedDescription)")
default:
print("Unhandled error. \(error.localizedDescription)")
}
}
After (v6)
- Objective C
- Swift
- (void)bannerView:(BLSBannerView * _Nonnull)bannerView didFailedToLoadWithError:(NSError * _Nonnull)error {
switch (error.code) {
case AdErrorWrongPlacement:
NSLog(@"Wrong placement Id. %@", error.localizedDescription);
break;
case AdErrorSDKUninitialized:
NSLog(@"BlueStack SDK is not initialized. %@", error.localizedDescription);
break;
default:
NSLog(@"Unhandled error");
break;
}
}
func onFailedToLoad(_ bannerView: BlueStackSDK.BannerView, _ error: any Error) {
guard let error = error as? AdError, let errorCode = AdErrorCode(rawValue: error.code) else { return }
switch errorCode {
case .wrongPlacement:
print("Wrong placement Id. \(error.localizedDescription)")
case .sdkUninitialized:
print("BlueStack SDK is not initialized. \(error.localizedDescription)")
default:
print("Unhandled error. \(error.localizedDescription)")
}
}
Note that the Swift enum cases have also been simplified.
For example, .BlueStackErrorWrongPlacement is now .wrongPlacement.
Native Ads
The native ad classes and delegate protocols have been renamed
to remove the MNG prefix.
The ad loading, rendering, and interaction logic remains the same.
Class and Protocol Renames
| v5 (Old) | v6 (New) |
|---|---|
MNGAdsSDKFactory | AdsSDKFactory |
MNGAdsAdapter | AdsAdapter |
MNGNAtiveObject | NativeObject |
MNGPreference | Preference |
MNGAdsAdapterNativeDelegate | AdsAdapterNativeDelegate |
MNGDisplayType | DisplayType |
Factory Initialization
Before (v5)
- Objective C
- Swift
nativeAdsFactory = [[MNGAdsSDKFactory alloc] init];
nativeAdsFactory.nativeDelegate = self;
nativeAdsFactory.placementId = @"/YOUR_APP_ID/PLACEMENT_ID";
nativeAdFactory = MNGAdsSDKFactory()
nativeAdFactory.nativeDelegate = self
nativeAdFactory.placementId = "/YOUR_APP_ID/PLACEMENT_ID"
After (v6)
- Objective C
- Swift
nativeAdsFactory = [[AdsSDKFactory alloc] init];
nativeAdsFactory.nativeDelegate = self;
nativeAdsFactory.placementId = @"/YOUR_APP_ID/PLACEMENT_ID";
nativeAdFactory = AdsSDKFactory()
nativeAdFactory.nativeDelegate = self
nativeAdFactory.placementId = "/YOUR_APP_ID/PLACEMENT_ID"
Loading with Preferences
Before (v5)
- Objective C
- Swift
MNGPreference *preferences = [[MNGPreference alloc] init];
[nativeAdsFactory loadNativeWithPreferences:preferences];
let preferences = MNGPreference()
nativeAdFactory.loadNative(withPreferences: preferences)
After (v6)
- Objective C
- Swift
Preference *preferences = [[Preference alloc] init];
[nativeAdsFactory loadNativeWithPreferences:preferences];
let preferences = Preference()
nativeAdFactory.loadNative(withPreferences: preferences)
Delegate Callbacks
Before (v5)
- Objective C
- Swift
- (void)adsAdapter:(MNGAdsAdapter *)adsAdapter nativeObjectDidLoad:(MNGNAtiveObject *)nativeObject {
NSLog(@"Native ad loaded");
// Use nativeObject to render your custom ad view
}
- (void)adsAdapter:(MNGAdsAdapter *)adsAdapter nativeObjectDidFailWithError:(NSError *)error withCover:(BOOL)cover {
NSLog(@"Native ad failed to load: %@", error.localizedDescription);
}
func adsAdapter(_ adsAdapter: MNGAdsAdapter!, nativeObjectDidLoad nativeObject: MNGNAtiveObject!) {
print("Native ad loaded")
// Use nativeObject to render your custom ad view
}
func adsAdapter(_ adsAdapter: MNGAdsAdapter!, nativeObjectDidFailWithError error: Error!, withCover cover: Bool) {
print("Native ad failed to load: \(error.localizedDescription)")
}
After (v6)
- Objective C
- Swift
- (void)adsAdapter:(AdsAdapter *)adsAdapter nativeObjectDidLoad:(NativeObject *)nativeObject {
NSLog(@"Native ad loaded");
// Use nativeObject to render your custom ad view
}
- (void)adsAdapter:(AdsAdapter *)adsAdapter nativeObjectDidFailWithError:(NSError *)error withCover:(BOOL)cover {
NSLog(@"Native ad failed to load: %@", error.localizedDescription);
}
func adsAdapter(_ adsAdapter: AdsAdapter!, nativeObjectDidLoad nativeObject: NativeObject!) {
print("Native ad loaded")
// Use nativeObject to render your custom ad view
}
func adsAdapter(_ adsAdapter: AdsAdapter!, nativeObjectDidFailWithError error: Error!, withCover cover: Bool) {
print("Native ad failed to load: \(error.localizedDescription)")
}
Other Ad Format Classes
The other ad format classes (InterstitialAd, RewardedAd,
BannerView) and their delegate protocols remain unchanged
in v6. No migration is needed for those formats.
Quick Find-and-Replace Summary
For most projects, the migration can be completed with a few find-and-replace operations:
| Find | Replace With |
|---|---|
BlueStack.sharedInstance | MobileAds.sharedInstance |
BlueStackPrivacySettings | PrivacySettings |
BlueStackError (class) | AdError |
BlueStackErrorCode | AdErrorCode |
BlueStackError (constant prefix) | AdError |
MAdvertiseError | AdError |
MNGAdsSDKFactory | AdsSDKFactory |
MNGAdsAdapter | AdsAdapter |
MNGNAtiveObject | NativeObject |
MNGPreference | Preference |
MNGAdsAdapterNativeDelegate | AdsAdapterNativeDelegate |
MNGDisplayType | DisplayType |
After running find-and-replace, build your project and fix any remaining compiler errors. The Xcode compiler will flag any references to the old class names that were missed.
Need Help?
If you encounter issues during migration, please reach out to us. The v5 documentation is still available at iOS v5 for reference.
