Xamarin Forms in App Billing插件不起作用

问题描述 投票:1回答:1

我在Xamarin Forms项目中安装了应用内结算插件:Plugin

首先,我想在iOS上使用它,但该插件无法正常工作。它显示以下错误:Plugin.InAppBilling.Abstractions.InAppBillingPurchaseException: Cannot connect to iTunes Store at Plugin.InAppBilling.InAppBillingImplementation.PurchaseAsync (System.String productId, Plugin.InAppBilling.Abstractions.ItemType itemType, System.String payload, Plugin.InAppBilling.Abstractions.IInAppBillingVerifyPurchase verifyPurchase) ..

我认为我的productId或有效负载是错误的,应该在里面放什么?这是我的代码:

          try
            {
                var productId = "mySKU";

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

                if (!connected)
                {
                    //Couldn't connect to billing, could be offline, alert user
                    return;
                }

                //try to purchase item
                var purchase = await CrossInAppBilling.Current.PurchaseAsync(productId, ItemType.Subscription, "payload");
                if (purchase == null)
                {
                    //Not purchased, alert the user
                }
                else
                {
                    //Purchased, save this information
                    var id = purchase.Id;
                    var token = purchase.PurchaseToken;
                    var state = purchase.State;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //Something bad has occurred, alert user
            }
            finally
            {
                //Disconnect, it is okay if we never connected
                await CrossInAppBilling.Current.DisconnectAsync();
            }

我希望任何人都可以帮助我。预先感谢。

xamarin.forms xamarin.android xamarin.ios in-app-purchase in-app-billing
1个回答
0
投票

您必须先使用nuget设置ios设置:

https://help.apple.com/xcode/mac/current/#/dev88ff319e7

© www.soinside.com 2019 - 2024. All rights reserved.