BlueStack.SDK.Maui
1.0.0
See the version list below for details.
dotnet add package BlueStack.SDK.Maui --version 1.0.0
NuGet\Install-Package BlueStack.SDK.Maui -Version 1.0.0
<PackageReference Include="BlueStack.SDK.Maui" Version="1.0.0" />
paket add BlueStack.SDK.Maui --version 1.0.0
#r "nuget: BlueStack.SDK.Maui, 1.0.0"
// Install BlueStack.SDK.Maui as a Cake Addin #addin nuget:?package=BlueStack.SDK.Maui&version=1.0.0 // Install BlueStack.SDK.Maui as a Cake Tool #tool nuget:?package=BlueStack.SDK.Maui&version=1.0.0
BlueStack-SDK MAUI
Getting started
BlueStack-SDK MAUI library provides functionality to integrate native(Android and iOS) BlueStack SDK into MAUI project. Using this library developer can display ads on their application from Madvertise and other third-party ad networks.
Prerequisites
.NET:
- .NET 7.0
iOS:
- Xcode 14.3 or later
- Minimum iOS version 13.0
Android:
- Android 5.0 (API 21) or higher
Using BlueStackSDK MAUI library
Initialization
Initialize BlueStack sdk with appId, settings and a completion block.
public partial class MainPage : ContentPage
{
public MainPage() {
InitializeComponent();
Settings settings = new Settings(true);
BlueStackAds.Initialize("YOUR_APP_ID_HERE", settings, OnAdSDKInitialized);
}
private void OnAdSDKInitialized(InitializationStatus initializationStatus)
{
Debug.Print("BlueStack SDK has been initialized");
}
}
Showing Banner Ad
Step 1. Instantiate Banner Ad
You can instanstiate a Banner ad by adding it in XAML file.
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:BlueStack.Controls.BannerAdView"
xmlns:bannerAdView="clr-namespace:BlueStack.Controls.BannerAdView;assembly=BlueStack.SDK.Maui"
x:Class="BlueStack.SDK.Maui.DemoApp.MainPage">
<bannerAdView:BannerAdView
x:Name="BannerView"
WidthRequest="320"
HeightRequest="50"
PlacementId="YOUR_BANNER_PLACEMENT_HERE"/>
</ContentPage>
Step 2. Register event listeners
BannerAd exposes the following events through it's lifecycle.
Methods | Definition |
---|---|
OnBannerDidLoad | Ad is successfully loaded and SDK is ready to display the ad. |
OnBannerDidFailed | The ad failed to load or display. An additional error parameter of type BlueStackError contains the reason of the failure. |
OnAdClicked | User has clicked the ad. Ad may open a link in browser. |
OnBannerDidRefresh | The banner ad has been refreshed |
OnBannerDidFailToRefresh | The banner ad has been failed to refresh |
To register for banner ad events, add the following code after instantiating BannerAd.
BannerView.SetBannerAdListener(this);
public void OnBannerDidLoad()
{
Logger.Debug(tag, "ShowBanner: onBannerAdLoaded");
}
public void OnBannerDidFailed(BlueStackError blueStackError)
{
Logger.Debug(tag, "BlueStack banner Ad errorCode: " + blueStackError.ErrorCode + " message: " + blueStackError.Message);
}
public void OnAdClicked()
{
Logger.Debug(tag, "BlueStack banner Ad Leaving Application");
}
public void OnBannerDidRefresh()
{
Logger.Debug(tag, "Ad Displayed");
}
public void OnBannerDidFailToRefresh(BlueStackError blueStackError)
{
Logger.Debug(tag, "errorCode: " + blueStackError.ErrorCode + " message: " + blueStackError.Message);
}
:::caution Make sure you only register event listener once. :::
Step 3. Load Banner ad
BannerAd takes AdSize
to load banner. It also have another Load
method that takes Preference
instance along with AdSize
. Banner Ad supports following ad sizes:
Ad Size | Definition |
---|---|
Banner | 320x50 |
DynamicBanner | 0x50 |
LargeBanner | 320x100 |
FullBanner | 468x60 |
Leaderboard | 728x90 |
DynamicLeaderboard | 0x90 |
MediumRectangle | 300x250 |
- Without Preference
BannerView.Load(AdSize.Banner);
- With Preference
private LoadBannerAdWithPreference() {
Preference _preference = new Preference();
Location myLocation = new Location(Location.NONE_PROVIDER)
{
Latitude = 35.757866,
Longitude = 10.810547
};
_preference.SetAge(25);
_preference.SetLanguage("en");
_preference.SetGender(Gender.Male);
_preference.SetKeyword("brand=myBrand;category=sport");
_preference.SetLocation(myLocation, 1);
_preference.SetContentUrl("https://madvertise.com/en/");
BannerView.Load(AdSize.Banner, _preference);
}
**Note : **
The setLocation method takes the following parameters:
- the Location instance.
- the CONSENT_FLAG value (corresponds to a int : 0,1,2 or 3).
- 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.
Destroy banner ad
Destroy banner ad if you want to create a new one.
BannerView.Destroy();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-android33.0 is compatible. net7.0-ios16.1 is compatible. net8.0-android was computed. net8.0-ios was computed. |
-
net7.0-android33.0
- BlueStack.SDK.Core.Android.Bridge.Binding (>= 1.0.0)
- Xamarin.AndroidX.Browser (>= 1.5.0.3)
- Xamarin.AndroidX.Lifecycle.LiveData (>= 2.6.1.3)
-
net7.0-ios16.1
- BlueStack.SDK.Bridging.iOS.Binding (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.