In app purchase cannot connect to itunes store ios 12 following InAppBillingPlugin for Xamarin

守給你的承諾、 提交于 2020-05-01 02:51:31

问题


I am trying to test in app purchases in my application following plugin. Also I have checked this and thousands of other officical/not official articles but there is no result. I do not thins there is a problem in my code because I asked another developer to share me his code and I use it in my app. In his project this code works perfect but I have InAppBillingPurchaseException "Can not connect to Itunes Store". I also logged out of my real accounts before entering sandbox credentials. This is the code but the I do not think the problem is here:

public async Task<bool> PurchaseItemAsync()
    {
        var billing = CrossInAppBilling.Current;
        LastExceptionMessage = null;

        try
        {
            var connected = await billing.ConnectAsync();
            if (connected == false)
                return false;

            var purchase = await billing.PurchaseAsync(_kProductId, ItemType.InAppPurchase, _kPayload);

            if (purchase == null)
                return false;
            else if (purchase.State == PurchaseState.Purchased)
                return true;
        }
        catch (InAppBillingPurchaseException ex)
        {
            OnPurchaseException(ex);
        }
        catch (Exception ex)
        {
            //Dlog.Error("Issue connecting: " + ex);
            LastExceptionMessage = ex.Message;
        }
        finally
        {
            await billing.DisconnectAsync();
        }

        return false;
    }

回答1:


In my case, bundleID in my app was not matching with the product id of In App purchase. I had bundle ID com.xam.sample in my app code. But product ID was testiap. So I created IAP with productID com.xam.sample.testiap and I was able to solve that error this way.



来源:https://stackoverflow.com/questions/53382036/in-app-purchase-cannot-connect-to-itunes-store-ios-12-following-inappbillingplug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!