Skip to content

BillingService on Android Not Working #731

@david-maw

Description

@david-maw

I found that the billing service on an Android Emulator was returning a "disconnected" error until I cheated and added a 1s delay after the call on InitializeAsync in the View Model. I really should have fixed up InitializeAsync to wait until the connection complete (or failed) notification cammeback, but I was too lazy! What worked for me was

            ....
            if (!_billingService.IsInitialized)
            {
                IsLoading = true;
                await Task.Delay(2000);
                var initialized = await _billingService.InitializeAsync();

                if (!initialized)
                {
                    await Application.Current!.Windows[0].Page!.DisplayAlertAsync("Error", "Failed to initialize billing service", "OK");
                    return;
                }
                await Task.Delay(1000); // Wait for the connection to be ready
            }

            var products = await _billingService.GetProductsAsync();
            ...

I also found the instructions a bit confusing, perhaps "Create products with IDs..." should read something like "Create products for Team license, Global license and Unlimited license with whatever product IDs you like", then move "Update the product IDs in your billing service to match those configured in Google Play Console" to be a following step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions