Jen143
Jen143

Reputation: 835

Xamarin In App Billing Plugin could not connect

I have used this plugin: https://github.com/jamesmontemagno/InAppBillingPlugin to implement the in app billing since the component was removed. I have installed the nuget: Plugin.InAppBilling

In the Android, I have create a class called InAppBillingService where I implement here to get the products and purchase an item. Here are the codes:

var billing = CrossInAppBilling.Current;
var connected = await billing.ConnectAsync();

And it returns false everytime. I could not connect.

I have added in my AndroidManifest this:

uses-permission android:name="com.android.vending.BILLING" />

And in the MainActivity:

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            InAppBillingImplementation.HandleActivityResult(requestCode, resultCode, data);
        }

And in onCreate: CrossCurrentActivity.Current.Init(this, bundle);

Please advice what else I should do so that I could connect. And what are other reasons why it always return false when tried to connect. I'm testing in emulator. Thank you.

Upvotes: 3

Views: 683

Answers (1)

K232
K232

Reputation: 1069

I'm testing in emulator.

That's the reason of the problem. As written here, Billing does not work on Android emulators. Use a real device.

Upvotes: 2

Related Questions