Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Ios app approved but IAP not working in production

Discussion in 'Unity IAP' started by bil_unity967, Mar 14, 2020.

  1. bil_unity967

    bil_unity967

    Joined:
    Feb 12, 2020
    Posts:
    6
    Hi,

    I'm using Codeless IAP in the most easy way.
    1 buy button to buy off ads. And 1 restore button.

    When the app is published to testflight. It all works. The buy button connects to itstore. Asks for my password and doen. Ads are gone. When I reinstall and use the restore button. It all works fine!.

    I publish the app. And it is accepted by apple. Hooray. My app is in production.

    I download it from the appstore and everything works fine except the IAP.
    They buy button doesn't do anything and neither does the restore.
    They just do nothing.

    What could cause this?

    Kind regards.
    Roel
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    Old thread but I am reviving because there are not many solutions out there to this unique problem.

    I have Unity Scripted IAP working for Android and iOS. Same product id's. Works well in Test Flight and on the Android Play Store but NOT in the iOS Apple App Store. My tax and financial details are all up-to-date for both platforms. The app did pass Apple review so I am guessing they skipped testing IAP this time around. What could be different between Test Flight and Production that causes this?
     
    Last edited: Aug 30, 2021
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What is the behavior in the App Store? Is initialization failing, or purchases not working? What version of IAP, is this for a new app?
     
  5. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    • Built on Unity IAP 4.0.3.
    • It is a young app. Pushed out a couple dozen builds - last version was a bump from 1.0.build_num to 1.1.build_num.
    • I personally have not seen IAP work on an Apple App Store build (production).
    • We did hit a snag along they way with the banking stuff as well as the product meta data. Resolved all of that a couple weeks ago.
    • Early builds were with Unity Codeless IAP but last week moved to scripted to get more control. Test Flight and Android have worked flawlessly since the port to scripted.
    • I believe initialization is failing because my code, during initialization, changes the button name to include the product name and price and the button is still showing the default text.
     
    Last edited: Aug 30, 2021
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    That wouldn't cause initialization to fail, but you may be experiencing a Null Reference Exception in other parts of your code as you mention. Are you able to reproduce with your live build? And the same build version in TestFlight works as expected? You'll want to check for null strings before setting your button name.
     
    Last edited: Aug 30, 2021
  7. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    Let me restate my comment about the button label. My IStoreListener.OnInitialized() method is where the button should be renamed with price affixed; label is not modified. When the "Remove Ads" button is tapped I check the value of my store manager initialized state and if false display a dialog informing the user that the App Store is not set up yet. This is happening - debugging by observation since it's a live App Store build that is failing.

    Yes the live Apple store build is the only configuration, out of four, where Unity IAP does not work.
    Yes the same build in Test Flight works as expected as do production and internal Android Play Store builds.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, as mentioned, I suspect an NRE that may be present in the live build and not TestFlight. It sounds like the renaming is failing, perhaps a price string is being returned empty. Show the code that you are using.
     
  9. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    The code below could be the culprit I will review and modify to ensure null safety and get back to this thread. Thanks for your time!

    Code (CSharp):
    1.         private void SetupRemoveAdsButtonForContent(Product product)
    2.         {
    3.             Debug.Log("OptionsMenu, setup remove ads button");
    4.             var priceFormatted = Utilities.ToFormattedCurrencyString(product.metadata.localizedPrice, product.metadata.isoCurrencyCode);
    5.             adsOffButtonTitle.SetText(ZString.Concat("Remove Ads: ", priceFormatted));
    6.         }
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please do! We did hear of one other report that mentioned isoCurrencyCode, I would suggest to test that first.
     
  11. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    I have found a way to capture logs from the Apple App Store Release of my app. The code above seems to work without a hitch. There is a lot to sift through as there is all kinds of system process stuff in their logs. Early analysis reveals that one key difference between the Test Flight and App Store builds are that the latter finds no products when the App Store query returns.

    So in reviewing my App Store developer pages I saw that the In-App products are still "Waiting for Review". I am now guessing that IAP products cannot be sold in the app until they come out of IAP review. What gets them out of review - I do not know. Time to talk to Apple.
     
  12. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    Saw this after my post - well my situation didn't uncover a problem with isoCurrencyCode - it cannot hurt to add a few checks there. Do you have any more specifics on what the role of isoCurrencyCode was?
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I saw it used in your code, what are you using it for? Perhaps I don't follow, I had meant I saw another report where isoCurrencyCode was null, but not confirmed. At any rate, are you able to reproduce? If IAP Initialization is failing, you would expect to see OnInitializedFailed called, can you confirm?
     
  14. mkieling

    mkieling

    Joined:
    Aug 9, 2020
    Posts:
    9
    Yes OnInitializedFailed is being called.

    I use isoCurrencyCode to look up the actual currency glyph. I'll check for isoCurrencyCode to be null. Though this is not an issue for me currently.

    This issue turned out to be a procedural rather than technical one. There seems to be some delay in reviewing the products I have created. Sandbox is happy to provide the products, but Live cannot find the products until they have been reviewed and approved by the Apple review process. So in Live I am getting an error that no products are found and the store initialization is halted.

    Thanks again for your help!
     
    JeffDUnity3D likes this.
  15. DarienMorris

    DarienMorris

    Joined:
    Jul 19, 2013
    Posts:
    1
    Did this eventually get resolved for you?

    I'm also running into this issue where everything was working on Testflight but not in production. I've read that there can be a delay before the new IAP is available after release, but it would be great to know what kind of time we are talking about.
     
  16. PloyGTM

    PloyGTM

    Joined:
    Aug 14, 2018
    Posts:
    3
    I also have the same issue here, All things were working on the test flight, but in our production, no one can purchase the IAP ( my IAP product is a subscription ), it's at the Try-Catch block of the validation

    Code (CSharp):
    1. #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
    2.  
    3.         var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
    4.             AppleTangle.Data(), Application.identifier);
    5.  
    6.         try
    7.         {
    8.             // On Apple stores, receipts contain multiple products.
    9.             var result = validator.Validate(e.purchasedProduct.receipt);
    10.             // For informational purposes, we list the receipt(s)
    11.             ShowDebug("Receipt is valid. Contents:");
    12.             foreach (IPurchaseReceipt productReceipt in result)
    13.             {
    14.                 ShowDebug(productReceipt.productID);
    15.                 ShowDebug(productReceipt.purchaseDate.ToString("yyyy-MM-dd hh:mm:ss"));
    16.                 ShowDebug(productReceipt.transactionID);
    17.                 ShowDebug("------------------------");
    18.             }
    19.         }
    20.         catch (IAPSecurityException)
    21.         {
    22.             ShowDebug("Invalid receipt, not unlocking content");
    23.             validPurchase = false;
    24.         }
    25. #endif
    inside 'public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)'

    I still don't know why it's happening, All the price/IAP items are fetching correctly
    for now, I would regenerate Obfuscate and see again in production if it was the validator problem...
     
  17. codxr

    codxr

    Joined:
    Jun 19, 2019
    Posts:
    11