Search Unity

iOS 14 Storekit Testing partially working with Unity IAP

Discussion in 'Unity IAP' started by AakashDP, Sep 29, 2020.

  1. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    I am trying to use the new StoreKit testing features in iOS 14 and Xcode 12 (https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_in_xcode) with Unity IAP but I am not able to get the full functionality out of the new testing tools when building with Unity.

    My flow is as follows:
    1. Make an iOS build in Unity (I'm on 2019.4.11).
    2. Open the Xcode project when the build is complete and create a StoreKit Configuration File and assign it in the Run Debug scheme.
    3. Configure a few of the IAPs which UnityPurchasing will request from the App Store in the StoreKit Configuration File.
    4. Open the StoreKit Transactions window in Xcode (Debug -> StoreKit -> Manage Transactions).
    5. Install and Run the game on an iOS 14 device through Xcode.

    What will happen is all the products returned from IStoreController will have all the settings you configured in the StoreKit Configuration File and when you try to purchase the product, it will also display the correct price, title etc. on the native payment popup (Super good). However the StoreKit Transactions Manager never detects that the app is running or receives the transactions made in app.

    I have tried this in my own project and in an empty Unity project with no luck. If I make a new/empty iOS app in Xcode, add the StoreKit Configuration File and install it on a device, the StoreKit Transaction Manager Window will show that the app is running and is ready to intercept any transactions. The demo shown in the link I shared above (available here: https://github.com/appcoda/StoreKitDemo/) also works.

    Any help with this would be really appreciated. The new tools for testing IAP & Subscriptions in iOS 14 and Xcode 12 seem incredibly useful.
     
    JustAnotherDude and GiverDP like this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I agree! It does sound incredibly useful, and a long time in coming. I just mentioned this to the IAP team as this will also greatly help with our QA testing here. Sorry I don't have an immediate answer for you, but we will definitely be looking into this. We are booked solid with our current efforts and a bit resource constrained, but I will definitely speak up for this feature, hopefully get some progress in an upcoming release.
     
    JustAnotherDude and AakashDP like this.
  3. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    Thanks @JeffDUnity3D , I'll be looking forward to hearing back for you
     
    GiverDP likes this.
  4. VoxelMatt

    VoxelMatt

    Joined:
    Apr 22, 2015
    Posts:
    42
    I'm currently having the same issue trying to test IAPs using StoreKit - the "Manage Transactions" Window is always empty.
     
    GiverDP likes this.
  5. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    GiverDP likes this.
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Not yet, I mentioned to the IAP team and we agree it sounds like a great feature for an upcoming release, no time frame yet
     
  7. VoxelMatt

    VoxelMatt

    Joined:
    Apr 22, 2015
    Posts:
    42
    @AakashDP I've tested and the Transaction Window works correctly in Unity 2018.4.x (Just not 2019.4 or 2020.x)

    @JeffDUnity3D It would be incredibly helpful if there was an easy way to replace the Apple Root Certificate (Apple Tangle) with the StoreKitTest Certificate from Apple. I spent a full day to try and get the StoreKitTest Certificate can validate StoreKit purchases using UnityIAP - but there's issues in how the certificate is validated.

    Code (CSharp):
    1. UnityEngine.Purchasing.Security.InvalidX509Data: Exception of type 'UnityEngine.Purchasing.Security.InvalidX509Data' was thrown.
    2.   at UnityEngine.Purchasing.Security.DistinguishedName..ctor (LipingShare.LCLib.Asn1Processor.Asn1Node n) [0x000c3] in <25997e77b45246b0b2ef370b6ef8a61a>:0
    3.   at UnityEngine.Purchasing.Security.X509Cert.ParseNode (LipingShare.LCLib.Asn1Processor.Asn1Node root) [0x000cb] in <25997e77b45246b0b2ef370b6ef8a61a>:0
    4.   at UnityEngine.Purchasing.Security.X509Cert..ctor (System.Byte[] data) [0x00025] in <25997e77b45246b0b2ef370b6ef8a61a>:0
    5.   at UnityEngine.Purchasing.Security.AppleValidator..ctor (System.Byte[] appleRootCertificate) [0x00013] in <25997e77b45246b0b2ef370b6ef8a61a>:0
    I've made a minimal bug report to reproduce the issue :) (Case 1285995)
     
    Last edited: Oct 19, 2020
    AakashDP likes this.
  8. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    Thanks for sharing about 2018.4 working! I was also expericing those errors when it came to validating receipts (randomly and not consistently), good to know that I'm not alone with that
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please share your logs from the XCode console when it works and doesn't, if possible. It sounds like a possibly different issue. Engineering is working on StoreKit testing.
     
  10. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    Hi @JeffDUnity3D , any news on the progess of Storekit testing support?
     
  11. VoxelMatt

    VoxelMatt

    Joined:
    Apr 22, 2015
    Posts:
    42
    I'd just like to add a note here. The big BIG reason why this feature is important is that the Transaction Window and StoreKit testing is the only way to debug the "Ask To Buy" feature on iOS without shipping an update and spending real money on real IAP.
     
    AakashDP likes this.
  12. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    Thats the exact scenario I was trying to test last year when this was posted
     
  13. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    My solution last year was to do a super simple/basic IAP implementation in an empty Unity 2018 project and write my logic to handle Deferred purchases and test it with StoreKit testing. When everything worked, then I migrated it to the main project which is in Unity 2019.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Storekit2 testing is a couple of months away.
     
  15. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    How about support for the Storekit which was availble since last year with iOS 14 and only partially works in newer Unity versions like this thread mentions? :)
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will be looking into this in the StoreKit2 time frame, we don't have the resources currently.
     
  17. nabergh

    nabergh

    Joined:
    Jun 22, 2019
    Posts:
    7
    The most important issue I'm having with StoreKit integration is the receipt validation. According to Apple docs, "StoreKit in Xcode generates receipts that are valid only in the test environment". https://developer.apple.com/documen...pp_purchase/testing_in-app_purchases_in_xcode
    I know how to get the certificate that StoreKit uses, but I don't know how to use that when validating my IAP using StoreKit. Every time I try, I get a IAPSecurityException. Is there an easy way to make Unity IAP aware of the StoreKit cert for testing?
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I will check with the team. In the meantime, what is the exception text? You can catch this exception, if it helps, with a try/catch block.
     
  19. nabergh

    nabergh

    Joined:
    Jun 22, 2019
    Posts:
    7
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Good catch!
     
  21. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I don't have AppleStoreKitTestTangle.cs in the generated folder. I'm using the latest verified package 4.1.3.
     
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you generate the tangle files from the IAP menu in the Unity Editor? I'm seeing it on my system here. You might try using "dir *tangle*.* /s" from the root of the project to confirm.
     
    andymads likes this.