Aller au contenu principal

iOS Migration Guide — BlueStack SDK v5 to v6

· 6 minutes de lecture
Md. Shadman Sakib
Md. Shadman Sakib
BlueStack SDK Team

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)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[BlueStack sharedInstance] initializeWithAppID:@"YOUR_APP_ID_HERE" completion:^(InitializationStatus * _Nonnull initializationStatus) {

}];
return YES;
}

After (v6)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[BLSMobileAds sharedInstance] initializeWithAppID:@"YOUR_APP_ID_HERE" completion:^(InitializationStatus * _Nonnull initializationStatus) {

}];
return YES;
}

Privacy Settings

The privacy settings class has been renamed from BlueStackPrivacySettings to PrivacySettings.

Before (v5)

[BlueStackPrivacySettings setIsAgeRestrictedUser:YES];
[BlueStackPrivacySettings setUserOptout:YES];

After (v6)

[PrivacySettings setIsAgeRestrictedUser:YES];
[PrivacySettings setUserOptout:YES];

Error Handling

Error classes and constants have been renamed to remove the BlueStack prefix.

v5v6
BlueStackErrorAdError
BlueStackErrorCodeAdErrorCode

Error Constants

All error constants have been renamed from the BlueStack* prefix to the AdError* prefix:

v5 Constantv6 Constant
BlueStackErrorWrongPlacementAdErrorWrongPlacement
BlueStackErrorAdServerAdErrorAdServer
BlueStackErrorDataAdServerAdErrorDataAdServer
BlueStackErrorSDKUninitializedAdErrorSDKUninitialized
BlueStackErrorCappedRequestAdErrorCappedRequest
BlueStackErrorLockedPlacementAdErrorLockedPlacement
BlueStackErrorBusyFactoryAdErrorBusyFactory
BlueStackErrorBusyAdErrorBusy
BlueStackErrorUnallowedBackgroundRequestAdErrorUnallowedBackgroundRequest
BlueStackErrorNoAdsAdErrorNoAds
MAdvertiseErrorInterstitialCooldownAdErrorInterstitialCooldown
BlueStackErrorAlreadyShownInterstitialAdErrorAlreadyShownInterstitial
BlueStackErrorRequestTimedOutAdErrorRequestTimedOut
BlueStackErrorMissingViewControllerAdErrorMissingViewController
BlueStackErrorUnableToDisplayAdAdErrorUnableToDisplayAd
BlueStackErrorAdExpiredAdErrorAdExpired

New Error Codes in v6

The following error codes are new in v6 and do not have v5 equivalents:

ConstantDescription
AdErrorNoInternetNo internet connection available.
AdErrorAlreadyShownAppOpenAn app open ad is already being displayed.
AdErrorNoAdapterFoundForPlacementNo mediation adapter found for the placement.
AdErrorAdapterClassNotFoundThe adapter class could not be found.
AdErrorInternalAn unexpected internal error occurred.

Before (v5)

- (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;
}
}

After (v6)

- (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;
}
}
info

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)
MNGAdsSDKFactoryAdsSDKFactory
MNGAdsAdapterAdsAdapter
MNGNAtiveObjectNativeObject
MNGPreferencePreference
MNGAdsAdapterNativeDelegateAdsAdapterNativeDelegate
MNGDisplayTypeDisplayType

Factory Initialization

Before (v5)

nativeAdsFactory = [[MNGAdsSDKFactory alloc] init];
nativeAdsFactory.nativeDelegate = self;
nativeAdsFactory.placementId = @"/YOUR_APP_ID/PLACEMENT_ID";

After (v6)

nativeAdsFactory = [[AdsSDKFactory alloc] init];
nativeAdsFactory.nativeDelegate = self;
nativeAdsFactory.placementId = @"/YOUR_APP_ID/PLACEMENT_ID";

Loading with Preferences

Before (v5)

MNGPreference *preferences = [[MNGPreference alloc] init];
[nativeAdsFactory loadNativeWithPreferences:preferences];

After (v6)

Preference *preferences = [[Preference alloc] init];
[nativeAdsFactory loadNativeWithPreferences:preferences];

Delegate Callbacks

Before (v5)

- (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);
}

After (v6)

- (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);
}

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:

FindReplace With
BlueStack.sharedInstanceMobileAds.sharedInstance
BlueStackPrivacySettingsPrivacySettings
BlueStackError (class)AdError
BlueStackErrorCodeAdErrorCode
BlueStackError (constant prefix)AdError
MAdvertiseErrorAdError
MNGAdsSDKFactoryAdsSDKFactory
MNGAdsAdapterAdsAdapter
MNGNAtiveObjectNativeObject
MNGPreferencePreference
MNGAdsAdapterNativeDelegateAdsAdapterNativeDelegate
MNGDisplayTypeDisplayType
astuce

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.