问题
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