Hi guys,
I am unable to restore my previous purchases using the InAppPurchaseManager , once I have closed the application down and loaded it again on an actual iPhone.
When I run the debugger in simulation mode, it works as expected. If I restart the Debugger, it checks to see if the product has been purchased, and it has. Great. However, once I run it against iTunes on a device, it fails to realize that I have persisted the previous purchases to the phone. There doesn't seem to be any persist errors occurring either. Just to note, it successfully makes the iTunes purchase in the Sandbox environment.
Here is my Persistance logic within the AppDelegate method.
private void InitializeInAppPurchaseManager()
{
// Assembly public key
string value = Security.Unify(
new string[] { "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtpopeFYhDOOsufNhYe2PY97azBQBJoqGSP/XxsgzQgj3M0MQQ0WE0WDwPKoxlo/MIuoadVR5q2ZRs3rTl",
"UsH9vYUPr/z0/O8kn5anQHshQkHkeHsA8wbyJGGmwcXqvZr1fnzFOFyHL46s47vOJBLc5x30oieJ02dNxdBcy0oFEJtJS5Ng5sm6YUv9ifgxYOqMr/K61HNw6tP0j",
"vi6vLv2ro/KXO0ADVxcDxEg+Pk16xVNKgnei8M09PJCgA9bWNyeSsD+85Jj9+OZGsS/DN7O7nrGuKx8oAg/lE6a2eCQHh9lXxSPlAFAMH2FB8aNxUeJxkByW+6l/S",
"yqvVlOeYxAwIDAQAB" },
new int[] { 0, 1, 2, 3 });
// Initialize the In App Purchase Manager
_purchaseManager.SimulateiTunesAppStore = false;
_purchaseManager.PublicKey = value;
_purchaseManager.CheckInternetConnection = true;
// Warn user that the store is not available
if (_purchaseManager.CanMakePayments)
{
Console.WriteLine("Xamarin.InAppBilling: User can make payments to iTunes App Store.");
}
else
{
//Display Alert Dialog Box
using (var alert = new UIAlertView("Apple Store", "Sorry but you cannot make purchases from the In App Billing store. Please try again later.", null, "OK", null))
{
alert.Show();
}
}
// Warn user if the Purchase Manager is unable to connect to
// the network.
_purchaseManager.NoInternetConnectionAvailable += () =>
{
Console.WriteLine("No open internet connection is available");
};
// Show any invalid product queries
_purchaseManager.ReceivedInvalidProducts += (productIDs) =>
{
// Display any invalid product IDs to the console
Console.WriteLine("The following IDs were rejected by the iTunes App Store:");
foreach (string ID in productIDs)
{
Console.WriteLine(ID);
}
Console.WriteLine(" ");
};
// Report the results of the user restoring previous purchases
_purchaseManager.InAppPurchasesRestored += (count) =>
{
};
// Report miscellanous processing errors
_purchaseManager.InAppPurchaseProcessingError += (message) =>
{
Console.WriteLine(message);
};
// Report any issues with persistence
_purchaseManager.InAppProductPersistenceError += (message) =>
{
Console.WriteLine(message);
};
// Setup automatic purchase persistance and load any previous purchases
_purchaseManager.AutomaticPersistenceType = InAppPurchasePersistenceType.LocalFile;
_purchaseManager.AutoPersistAfterPurchase = true;
_purchaseManager.PersistenceFilename = "AtomicData";
_purchaseManager.ShuffleProductsOnPersistence = false;
_purchaseManager.RestoreProducts();
// Setup the list of simulated purchases to restore when doing a simulated restore of pruchases
// from the iTunes App Store
_purchaseManager.SimulatedRestoredPurchaseProducts = AppStoreProducts[0];
}
If I then call this method and check an already purchased product, it returns false
//create the in app purchase manager InitializeInAppPurchaseManager();
//had the user purchased the consumable? var hasBeenPurchased = _purchaseManager.ProductPurchased("com.test.nonconsumable.product);
Always returns false on the iPhone/iPad.
Will this work once its been deployed to the App store, or is this just default behavior once you test in on an actual Phone?
Has anyone else had experience with this component? What am I not doing?
Regards Justin