Companova.Maui.Common.Android.Services
0.0.1-preview
dotnet add package Companova.Maui.Common.Android.Services --version 0.0.1-preview
NuGet\Install-Package Companova.Maui.Common.Android.Services -Version 0.0.1-preview
<PackageReference Include="Companova.Maui.Common.Android.Services" Version="0.0.1-preview" />
paket add Companova.Maui.Common.Android.Services --version 0.0.1-preview
#r "nuget: Companova.Maui.Common.Android.Services, 0.0.1-preview"
// Install Companova.Maui.Common.Android.Services as a Cake Addin #addin nuget:?package=Companova.Maui.Common.Android.Services&version=0.0.1-preview&prerelease // Install Companova.Maui.Common.Android.Services as a Cake Tool #tool nuget:?package=Companova.Maui.Common.Android.Services&version=0.0.1-preview&prerelease
MauiCommonAndroidServices
Maui implementation of Common Android Services:
- Interstitial Ads version 122.3.0
- Firebase Analytics version 121.3.0.4
- In-App-Purchases supporting Billing library 5.2.0
Build Status:
master | dev |
---|---|
Setup:
<a href="https://www.nuget.org/packages/Companova.Maui.Common.Android.Services/"> <img alt="Nuget" src="https://img.shields.io/nuget/v/Companova.Maui.Common.Android.Services"> </a>
Available on NuGet: Companova.Maui.Common.Android.Services
Test App
Refer to Test App for detailed usage patterns
https://github.com/companova/MauiCommonAndroidServices/tree/dev/test
How to setup:
- Ensure your Application is published to Google Play and registered in Firebase.
- Update google-services.json with your Application google-services.json file from Firebase
- Replace package name 'com.company.appname' in AndroidManifest.xml to your application name
- If you wish to test Interstitial Ads with your Application Ad Ids, replace AdMob Test ApplicationId and
_interstitialAdUnitId
with your Application specific values.
Interstitial Ads
private IInterstitialService _interstitialService => CrossAndroidServices.InterstitialService;
private async Task InitializeAds()
{
// Interstitial Ads
_interstitialService.Initialize(true, _interstitialAdUnitId, null);
await _interstitialService.LoadInterstitialAsync();
}
Firebase Analytics
// Initialize Firebase Analytics
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.GetInstance(Application);
//Set Firebase to the Analytics Service
CrossAndroidServices.AnalyticsService.SetFirebaseAnalytics(firebaseAnalytics);
// Use Analytics to Log Event
CrossAndroidServices.AnalyticsService.LogEvent("test_event");
In-App-Purchases
public async Task InitializeInAppPurchaseAsync()
{
_inAppPurchaseService = CrossAndroidServices.InAppPurchaseService;
// Set Current Activity
_inAppPurchaseService.SetActivity(this);
// Connect to the Billing Client
await _inAppPurchaseService.StartAsync();
// First, get the products
IEnumerable<Product> products = await _inAppPurchaseService.LoadProductsAsync(new string[] { productId }, ProductType.NonConsumable);
// Initiate the purchase process
InAppPurchaseResult purchase = await _inAppPurchaseService.PurchaseAsync(productId);
// If the product got purchased and is not yet acknowledged,
// then activate the product. Otherwise, Google refunds it.
// From: https://developer.android.com/google/play/billing/integrate#acknowledge
// If you do not acknowledge a purchase within three days, the user automatically receives a refund, and Google Play revokes the purchase.
if (purchase.State == PurchaseState.Purchased && !purchase.Acknowledged)
{
await _inAppPurchaseService.FinalizePurchaseAsync(purchase.PurchaseToken, ProductType.NonConsumable);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0-android34.0 is compatible. net9.0-android was computed. |
-
net8.0-android34.0
- Xamarin.Android.Google.BillingClient (>= 6.2.1)
- Xamarin.Firebase.Analytics (>= 122.1.2.1)
- Xamarin.GooglePlayServices.Ads (>= 123.6.0)
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 |
---|---|---|
0.0.1-preview | 28 | 1/17/2025 |
Upgraded to Android SDK 13, Android Billing Library to 6.2.1, Firebase Analytics to 122.1.2.1 and GooglePlayServices Ads to 123.6.0