Companova.Xamarin.Common.Android.Services
1.3.0
dotnet add package Companova.Xamarin.Common.Android.Services --version 1.3.0
NuGet\Install-Package Companova.Xamarin.Common.Android.Services -Version 1.3.0
<PackageReference Include="Companova.Xamarin.Common.Android.Services" Version="1.3.0" />
paket add Companova.Xamarin.Common.Android.Services --version 1.3.0
#r "nuget: Companova.Xamarin.Common.Android.Services, 1.3.0"
// Install Companova.Xamarin.Common.Android.Services as a Cake Addin #addin nuget:?package=Companova.Xamarin.Common.Android.Services&version=1.3.0 // Install Companova.Xamarin.Common.Android.Services as a Cake Tool #tool nuget:?package=Companova.Xamarin.Common.Android.Services&version=1.3.0
XamarinCommonAndroidServices
Xamarin 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.Xamarin.Common.Android.Services/"> <img alt="Nuget" src="https://img.shields.io/nuget/v/Companova.Xamarin.Common.Android.Services"> </a>
Available on NuGet: Companova.Xamarin.Common.Android.Services
Test App
Refer to Test App for detailed usage patterns
https://github.com/companova/XamarinCommonAndroidServices/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. |
---|---|
MonoAndroid | monoandroid13.0 is compatible. |
-
MonoAndroid 13.0
- Xamarin.Android.Google.BillingClient (>= 5.2.0)
- Xamarin.Firebase.Analytics (>= 121.3.0.4)
- Xamarin.GooglePlayServices.Ads (>= 122.3.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 |
---|---|---|
1.3.0 | 226 | 1/2/2024 |
1.0.0 | 469 | 4/28/2022 |
0.0.4-preview | 181 | 4/23/2022 |
Upgraded to Android SDK 13, Android Billing Library to 5.2.0, Firebase Analytics to 121.3.0.4 and GooglePlayServices Ads to 122.3.0