Hi
I had a similar problem with another BillingClient framework.
Mine was solved by adding await to the function call:
bool billingConnected = await xFInAppBilling.ConnectAsync();
Hope it helps!
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, I am having a hard time setting up In-app purchases in my Xamarin native android app.
I am using XFInAppBilling which uses the new Xamarin.Android.Google.BillingClient packages from Nuget.
XFInAppBilling also uses Plugin.CurrentActivity.
In my AndroidManifest I have (but i've read with the new 3.0 billing library its not required)
<uses-permission android:name="com.android.vending.BILLING" />
This is how my MainActivity.cs looks like:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
SetContentView(Resource.Layout.activity_main);
CrossCurrentActivity.Current.Init(this, savedInstanceState);
var toolbar = FindViewById<AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
XFInAppBillingImplementation xFInAppBilling = new XFInAppBillingImplementation();
bool billingConnected = xFInAppBilling.ConnectAsync().Result;
}
I have already published my APK to google console for internal testing. And I have an active in-app product listed on Google play console.
When I debug my app from visual studio on an actual device; in the ConnectAsync() method of XFInAppBillingImplementation.cs:
public async Task<bool> ConnectAsync()
{
try
{
_tcsConnect = new TaskCompletionSource<bool>();
BillingClient = BillingClient.NewBuilder(CurrentContext).EnablePendingPurchases().SetListener(this).Build();
BillingClient.StartConnection(this);
return await _tcsConnect?.Task; //hangs here
}
catch (Exception ex)
{
throw ex;
}
}
my app just hangs at the return await _tcsConnect?.Task line.
Looking for guidance to setting up iap.
Hi
I had a similar problem with another BillingClient framework.
Mine was solved by adding await to the function call:
bool billingConnected = await xFInAppBilling.ConnectAsync();
Hope it helps!