@ap-unity
Hi there.
I updated my gist: Purchaser2.cs · GitHub
ReceiptCheck now looks like this:
public void ReceiptCheck ()
{
iap.labelCenter.text = "RECEIPT CHECK\n";
if (Application.platform == RuntimePlatform.Android ||
Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.OSXPlayer) {
Product[] products = m_StoreController.products.all;
iap.labelCenter.text += "products.Length is: " + products.Length + "\n";
CrossPlatformValidator validator = new CrossPlatformValidator (null, AppleTangle.Data (), Application.bundleIdentifier);
for (int i = 0; i < products.Length; i++) {
iap.labelCenter.text += "Entered for " + i + "\n";
IPurchaseReceipt[] result;
if (products[i].receipt != null) {
result = validator.Validate(products[i].receipt);
iap.labelCenter.text += result[i];
for (int j = 0; j < result.Length; j++) {
if (result[j].productID == kProductNameAppleNonConsumable) {
iap.labelCenter.text += "Entered if " + i + "\n";
iap.labelCenter.text += result[j].productID + "\n";
iap.labelCenter.text = "IAP SUCESS";
iap.IAPBought();
}
}
} else {
iap.labelCenter.text += "null " + i + "\n";
}
// if (result[i].productID == kProductIDNonConsumable) {
// iap.labelCenter.text += "Entered if " + i + "\n";
// iap.labelCenter.text += result[i].productID + "\n";
// iap.labelCenter.text = "IAP SUCESS";
// iap.IAPBought();
// }
}
}
}
I am getting this from Xcode:
2017-01-04 23:48:51.439809 alphabet[1631:498198] [DYMTLInitPlatform] platform initialization successful
2017-01-04 23:48:51.538700 alphabet[1631:498078] → registered mono modules 0x100e3ffc0
2017-01-04 23:48:51.668714 alphabet[1631:498078] You’ve implemented -[ application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add “remote-notification” to the list of your supported UIBackgroundModes in your Info.plist.
→ applicationDidFinishLaunching()
2017-01-04 23:48:51.725113 alphabet[1631:498078] Metal GPU Frame Capture Enabled
2017-01-04 23:48:51.725396 alphabet[1631:498078] Metal API Validation Enabled
→ applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Init: screen size 1136x640
Initializing Metal device caps: Apple A9 GPU
Initialize engine version: 5.4.2f2 (b7e030c65c9b)
UnloadTime: 1.104416 ms
2017-01-04 23:48:52.201283 alphabet[1631:498078] UnityIAP:Requesting 1 products
Setting up 1 worker threads for Enlighten.
Thread → id: 16f53f000 → priority: 1
2017-01-04 23:48:52.264850 alphabet[1631:498078] UnityIAP:Requesting product data…
2017-01-04 23:48:53.928255 alphabet[1631:498078] UnityIAP:Received 1 products
OnInitialized: PASS
Purchaser:OnInitialized(IStoreController, IExtensionProvider)
UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
UnityEngine.Purchasing.AppleStoreImpl:processMessage(String, String, String, String)
UnityEngine.Purchasing.Extension.UnityUtil:Update()
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)
IndexOutOfRangeException: Array index is out of range.
at Purchaser.OnInitialized (IStoreController controller, IExtensionProvider extensions) [0x00000] in :0
at UnityEngine.Purchasing.PurchasingManager.CheckForInitialization () [0x00000] in :0
at UnityEngine.Purchasing.PurchasingManager.OnProductsRetrieved (System.Collections.Generic.List`1 products) [0x00000] in :0
at UnityEngine.Purchasing.AppleStoreImpl.OnProductsRetrieved (System.String json) [0x00000] in :0
at UnityEngine.Purchasing.AppleStoreImpl.ProcessMessage (System.String subject, System.String payload, System.String receipt, System.String transactionId) [0x00000] in :0
at UnityEngine.Purchasing.Extension.UnityUtil.Update () [0x00000] in :0
(Filename: currently not available on il2cpp Line: -1)
On my debugging I am getting:
products.Length is: 1
Entered for 0
null 0
So basically this is never true if(products*.receipt !=null)*
Would you please let me know what I am doing wrong. As far as I understand I am following your directions but I am not getting the expected outcome, which is enabling an already purchased product to be available after app is restarted or device has shut down.
Thanks a lot for your help