BlueStack.SDK.Maui 1.0.0-alpha1

This is a prerelease version of BlueStack.SDK.Maui.
There is a newer version of this package available.
See the version list below for details.
dotnet add package BlueStack.SDK.Maui --version 1.0.0-alpha1                
NuGet\Install-Package BlueStack.SDK.Maui -Version 1.0.0-alpha1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlueStack.SDK.Maui" Version="1.0.0-alpha1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlueStack.SDK.Maui --version 1.0.0-alpha1                
#r "nuget: BlueStack.SDK.Maui, 1.0.0-alpha1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlueStack.SDK.Maui as a Cake Addin
#addin nuget:?package=BlueStack.SDK.Maui&version=1.0.0-alpha1&prerelease

// Install BlueStack.SDK.Maui as a Cake Tool
#tool nuget:?package=BlueStack.SDK.Maui&version=1.0.0-alpha1&prerelease                

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
{
    private BannerAd _bannerAd;

    public MainPage() {
        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 right after SDK finishes it's initialization. You have to pass the platform specific banner placement id and banner AdPosition in BannerAd constructor.

        _bannerAd = new BannerAd(adUnitId, AdPosition.Top);

Banner ad supports ad positions of following types:

Position value Definition
Top 0 Show banner at the top of the screen
Bottom 1 Show banner at the bottom of the screen

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.
OnBannerDisplay The banner ad has been displayed on the screen.
OnBannerHide The banner ad has been hidden.
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.

    _bannerAd.OnBannerDidLoad += (sender, args) =>
    {
        Debug.Log("OnBannerDidLoad");
    };

    _bannerAd.OnBannerDidFailed += (sender, args) =>
    {
        Debug.LogError("OnBannerDidFailed: " + args.Message);
    };

    _bannerAd.OnBannerDisplay += (sender, args) => 
    { 
        Debug.Log("OnBannerDisplay"); 
    };
    _bannerAd.OnBannerHide += (sender, args) => 
    { 
        Debug.Log("OnBannerHide"); 
    };
    _bannerAd.OnAdClicked += (sender, args) => 
    { 
        Debug.Log("OnAdClicked"); 
    };
    _bannerAd.OnBannerDidRefresh += (sender, args) =>
    {
        Debug.Log("OnBannerDidRefresh");
    };
    _bannerAd.OnBannerDidFailToRefresh += (sender, args) =>
    {
        Debug.LogError("OnBannerDidFailToRefresh: " + args.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
_bannerAd.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/");

      _bannerAd.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.

Step 4. Show Banner ad

After loading the banner ad you can request it to be displayed.

_bannerAd.Show();

Hide Banner ad

Banner Ad can be set to be hidden also.

_bannerAd.Hide();

Change banner ad position

You can set banner ad position runtime.

_bannerAd.SetPosition(adPosition);

Destroy banner ad

Destroy banner ad if you want to create a new one.

_bannerAd.Destroy();
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-android33.0 is compatible.  net7.0-ios was computed.  net7.0-ios16.1 is compatible.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.8 713 7/4/2024
1.1.7 104 6/25/2024
1.1.6 289 6/10/2024
1.1.5 84 6/7/2024
1.1.4 116 5/31/2024
1.1.3 167 5/30/2024
1.1.2 273 5/16/2024
1.1.1 1,058 2/7/2024
1.1.0 149 1/16/2024
1.0.0 201 11/24/2023
1.0.0-alpha1 92 8/30/2023
1.0.0-alpha.2 66 11/7/2023