Search Unity

Unity IAP not working on iPhone 12

Discussion in 'Unity IAP' started by PopsawayGames, Sep 24, 2021.

  1. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Hello!

    I have a problem with in app purchases, it could be bound to the recent release of iOS 15, I still don't know.
    I'm using Easy Mobile Pro as plugin to cross platform easily. Unity IAP and Easy Mobile Pro are both updated to last release.
    The very odd thing is that IAP work on every Android device AND every Apple device, except for iPhone 12 pro max. I tested it on iPhone 6, SE, X, 11, 11 pro...so I really don't think it's related to EMP plugin or to my code, just because it's working like a charm on every other platform. On iPhone 12 doesn't work ( I tested with iOS 14.8 before the update of iOS 15, both don't work).
    Also, I noted that face id is not being called and the old UI with password check si called instead. Could be necessary to install some sort of face detection package? Is someone else experiencing this issue?
    I've been rejected three time from App review on Apple Store and our client is very disappointed for having it only on Android.
    Please I need some kind of help, I've been working on it from 4 days and still nothing. Thanks a lot
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    When you say "doesn't work", can you elaborate? Is IAP initialization failing? Or is it a purchase that is failing? It appears that you can reproduce, so please provide the XCode logs which should help to troubleshoot https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/
     
    PopsawayGames likes this.
  3. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Hi Jeff,
    Sorry for the lack of information, I was a bit worried. I put some alerts log to see what was happening, the initialization is done correctly, otherwise I should see an alert on screen. The strange behaviour is the "BuyOffer" button: once tapped the offer to buy, it simply does nothing. On other devices it shows correctly the password check to buy the IAP, on iPhone 12 nothing at all (consumable and not). I put alerts in every check, null product, incorrect product id, ecc...it does not show anything, so it looks like InitiatePurchase is being called ( but I'm not sure ).
    Unfortunately we don't have a Mac, I build on MacInCloud with XCode 13. Is there another method to see logs? Thanks
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You would need to instrument your build and test yourself, or release to TestFlight with limited testers. Write the debug output to the UI, perhaps into a top layer text element. This is what I do in the Sample IAP Project here. It's handy for debugging when you don't have access to the device logs, I place a MyDebug() statement in every purchasing method so I can properly debug. https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270

    1. Drop a text object into your scene, perhaps on the current canvas
    2. Make it big enough to fit several lines of debug output
    3. Pass this object into the purchasing script

    Code (CSharp):
    1.  
    2. public Text myText;
    3. ...
    4.  
    5. public void OnInitializeFailed(InitializationFailureReason error)
    6.     {
    7.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    8.         MyDebug("OnInitializeFailed InitializationFailureReason:" + error);
    9.     }
    10.  
    11. private void MyDebug(string debug)
    12.     {
    13.      
    14.         Debug.Log(debug);
    15.         myText.text += "\r\n" + debug;
    16.     }
     
  5. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Thanks for advice Jeff. I will work on it and see if initialization is done properly. By the way, I just tested on a friend's iPhone 12 with TestFlight and it works with iOS 14.8. He's updating to iOS 15 to re-test, I must know if it's related to iOS 15 release as I think.
    I'm going to share the results as soon as I have them.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I just updated my iPhone 12 to iOS 15 and IAP 4.0.3 is working for me. I was able to make a purchase. Are you using Scripted or Codeless IAP? I'm testing with Scripted IAP (the Sample IAP Project v2)
     
  7. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    It's very very odd. The other iPhone 12 of my friend, after iOS 15, still works, as yours. BUT, he did not turn on face detection. Is your phone using it? It looks like the only difference.
    However, I tried testing with alert and logs and everything is fine, I put an alert just before InitiatePurchase and it shows up, for every product. So IAP is being initialized correctly, it loads products correctly and InitiatePurchase correctly. Then, there is a veeeery long waiting to show password check after an offer button is tapped ( 20 seconds and it shows up rarely ).
    For IAP version, I'm not sure but I think I'm using scripted one, because I use the plugin Easy Mobile Pro to simplify cross platform for a lot of things.
     
  8. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    I was wrong, after iOS 15 update every in app purchase stopped working. It's very strange that every iPhone works and the two that updated to iOS 15 stopped working with the same build.
    I will try to test with your Sample IAP project V2 as you said. I really hope to solve this problem :(
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide the device logs with the additional Debug.Log output as mentioned.
     
  10. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Is there a method to have logs without an iPhone plugged in a Mac?
    Also, do you have an idea on why face ID is not used and the IAP still uses password?
    Thank you
     
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, please see this previous post https://forum.unity.com/threads/unity-iap-not-working-on-iphone-12.1174187/#post-7520681 Apple probably doesn't use FaceID because you would likely be logging in with a separate Sandbox account, not the phone profile account associated with FaceID on the device.
     
  12. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Ok thank you Jeff! I'll update as soon as I have news!
     
  13. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @Zhatos94,

    Have you resolved your problem yet?
    My game also has problems with IAP (v3.1.0, v3.2.3 & v4.0.3) on iOS 15.
    IAP always fails to initialize.

    Hi @JeffDUnity3D,
    This is my log:
    Code (CSharp):
    1. 2021-10-01 01:16:51.334103+0700 sniperzombies[1966:338835] UnityIAP UnityEarlyTransactionObserver: Created
    2. 2021-10-01 01:16:51.334889+0700 sniperzombies[1966:338835] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. 2021-10-01 01:16:51.426958+0700 sniperzombies[1966:338835] FCM: Loading UIApplication FIRFCM category
    4. 2021-10-01 01:16:51.505529+0700 sniperzombies[1966:338835] FIID: Loading UIApplication FIRIID category
    5. 2021-10-01 01:16:51.951184+0700 sniperzombies[1966:338835] You've implemented -[<UIApplicationDelegate> application:didReceiveRemoteNotification:fetchCompletionHandler:], but you still need to add "remote-notification" to the list of your supported UIBackgroundModes in your Info.plist.
    6. 2021-10-01 01:16:52.752986+0700 sniperzombies[1966:338835] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    7. Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]
    8. a background thread: -[UIApplication statusBarOrientation]
    9. Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
    10. 2021-10-01 01:17:20.533391+0700 sniperzombies[1966:339391] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication delegate]
    11. Main Thread Checker: UI API called on a background thread: -[UIApplication setDelegate:]
    12. 2021-10-01 01:17:21.315742+0700 sniperzombies[1966:339391] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication setDelegate:]
    13. IAPManager: Init product
    14. IAPManager:InitProducts()
    15. 2021-10-01 01:17:23.256265+0700 sniperzombies[1966:338835] UnityIAP: Requesting 66 products
    16. 2021-10-01 01:17:23.263578+0700 sniperzombies[1966:338835] UnityIAP: Requesting product data...
    17. 2021-10-01 01:17:58.266975+0700 sniperzombies[1966:338835] [BackgroundTask] Background Task 9 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
    Could you please take a look?
    The IAP work well on iOS < 15.

    Thank you so much,
    Huy
     
    Last edited: Sep 30, 2021
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm not seeing any errors that I recognize? How do the non-iOS15 logs compare? Is OnInitializedFailed being called?
     
  15. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
  16. PopsawayGames

    PopsawayGames

    Joined:
    Jan 2, 2018
    Posts:
    25
    Hello!
    I finally solved my problem. My company provided me a Mac Mini to debug my build.
    This is what happened to me: at initialization, Unity IAP recovers the products from Apple.
    This is a strange and unexpected behavious for me, because the products are somehow purchased, in fact OnPurchaseComplete was called for every product in my logs.
    Since I have some logic there that is bound to the offer to be bought (this is very bad and I will solve it), at initialization on app start, let's say, this logic was not valued and throwed a damned NullPointer (on the first product).
    That exception caused the cycle on products to be stopped, so when tester tapped on an offer button, the app was in a strange loop of never receiving the password field input panel.
    After catching exception, everything worked!
    I don't know why but on iOS 15 this bug caused every IAP to stop working, on older versions of iOS instead it worked ONLY on first app start, that's why I didn't notice it.
    As always, logs saved my life. Thanks a lot for help @JeffDUnity3D! I hope this will help you too @Huy_Ng
     
  17. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D

    After I put some logs, I get result as image below:
    IAPDebugLog.png

    And when I make a purchase, nothing happens because m_StoreController and m_StoreExtensionProvider are null.
    And of course OnInitialized & OnInitializedFailed are not called.
     
    Last edited: Oct 1, 2021
  18. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @Zhatos94
    In my case, I don't get any exception :(
     
  19. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Where are you initializing IAP in your code? Please post code with Code tags here (the Code: button in the edit ribbon), not as images, thanks. IAP initializes on non iOS12 devices for you? I have an iOS 12 device here and IAP work fine.
     
  20. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D,

    In my game:
    IAP does not initialize on iOS15. It works fine on iOS14.x, 13.x, ...
    The problem only occurred when Apple released iOS15.

    Here are my code:
    Code (CSharp):
    1.  
    2. public class IAPManager : MonoBehaviour, IStoreListener, IEventSender
    3. {
    4.     private static IAPManager _Instance;
    5.     public static IAPManager Instance
    6.     {
    7.         get
    8.         {
    9.             if (_Instance == null)
    10.             {
    11.                 GameObject gameObject = new GameObject("IAPManager");
    12.                 _Instance = gameObject.AddComponent<IAPManager>();
    13.             }
    14.             return _Instance;
    15.         }
    16.         set
    17.         {
    18.             _Instance = value;
    19.         }
    20.     }
    21.  
    22.     private IStoreController m_StoreController;
    23.     private IExtensionProvider m_StoreExtensionProvider;
    24.     private IAppleExtensions m_AppleExtensions;
    25.     private IGooglePlayStoreExtensions m_GooglePlayStoreExtensions;
    26.  
    27.     private IAPInitStatus m_IAPInitStatus = IAPInitStatus.None;
    28.     public IAPInitStatus Status
    29.     {
    30.         get
    31.         {
    32.             return m_IAPInitStatus;
    33.         }
    34.         set
    35.         {
    36.             m_IAPInitStatus = value;
    37.         }
    38.     }
    39.  
    40.     private void Start()
    41.     {
    42.         DontDestroyOnLoad(gameObject);
    43.     }
    44.  
    45.     public void Init()
    46.     {
    47.         InitProducts();
    48.     }
    49.  
    50.     void InitProducts()
    51.     {
    52.         Debug.Log("IAPManager: Init product");
    53.  
    54.         m_IAPInitStatus = IAPInitStatus.None;
    55.  
    56.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    57.  
    58.         foreach(var iap in ConfigIAPProduct.Instance.dataArray)
    59.         {
    60.             string productid = iap.ID;
    61.             ProductType producttype = iap.Type;
    62.             builder.AddProduct(productid, producttype, new IDs() { { productid, AppleAppStore.Name}, {productid, GooglePlay.Name}});
    63.         }
    64.  
    65.         UnityPurchasing.Initialize(this, builder);
    66.     }
    67.  
    68.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    69.     {
    70.         // Purchasing has succeeded initializing. Collect our Purchasing references.
    71.         Debug.Log("OnInitialized: PASS");
    72.  
    73.         // Overall Purchasing system, configured with products for this application.
    74.         m_StoreController = controller;
    75.         // Store specific subsystem, for accessing device-specific store features.
    76.         m_StoreExtensionProvider = extensions;
    77.  
    78.         m_AppleExtensions = extensions.GetExtension<IAppleExtensions>();
    79.         m_GooglePlayStoreExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
    80.  
    81.         // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature.
    82.         // On non-Apple platforms this will have no effect; OnDeferred will never be called.
    83.         m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred);
    84.  
    85.         m_IAPInitStatus = IAPInitStatus.Successed;
    86.     }
    87.  
    88.     public void OnInitializeFailed(InitializationFailureReason error)
    89.     {
    90.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    91.         Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
    92.  
    93.         if (waitProductId != "")
    94.         {
    95.             GameUtilities.HidePopupWaiting();
    96.         }
    97.  
    98.         m_IAPInitStatus = IAPInitStatus.Failed;
    99.     }
    100.  
    101.     public bool IsInitialized()
    102.     {
    103.         // Only say we are initialized if both the Purchasing references are set.
    104.         return m_StoreController != null && m_StoreExtensionProvider != null;
    105.     }
    106. }
    107.  
    Tomorrow, I will try your IAP with an empty project on iOS15.

    Thanks,
    Huy
     
  21. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I've tested IAP 4.0.3 on iOS 15 without issue so far. If you can reproduce, please provide the device logs from XCode, they will contain your Debug.Log statements to help in troubleshooting https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/
     
  22. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D,

    My game is using Unity 2019.4.17f1 (I have tried on Unity 2020.3.15f1 -- the result is the same)
    I have tested on iOS15 Official -- not iOS15 Beta.

    Here are the log:
    Code (CSharp):
    1. 2021-10-03 01:01:26.540227+0700 sniperzombies[2885:712402] UnityIAP UnityEarlyTransactionObserver: Created
    2. 2021-10-03 01:01:26.541285+0700 sniperzombies[2885:712402] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. 2021-10-03 01:01:26.647187+0700 sniperzombies[2885:712402] Built from '2019.4/staging' branch, Version '2019.4.17f1 (667c8606c536)', Build type 'Release', Scripting Backend 'il2cpp'
    4. -> applicationDidFinishLaunching()
    5. 2021-10-03 01:01:27.106758+0700 sniperzombies[2885:712402] Writing analzed variants.
    6. 2021-10-03 01:01:27.115492+0700 sniperzombies[2885:712402] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    7. -> applicationDidBecomeActive()
    8. GfxDevice: creating device client; threaded=1
    9. Initializing Metal device caps: Apple A12 GPU
    10. Initialize engine version: 2019.4.17f1 (667c8606c536)
    11. 2021-10-03 01:01:27.548115+0700 sniperzombies[2885:712402] Unbalanced calls to begin/end appearance transitions for <UnityViewControllerStoryboard: 0x105443e90>.
    12. UnloadTime: 1.254167 ms
    13. IAPManager: Init product
    14. IAPManager:InitProducts()
    15. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    16.  
    17. IAPManager: Begin add product
    18. IAPManager:InitProducts()
    19. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    20.  
    21. IAPManager: End add product
    22. IAPManager:InitProducts()
    23. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    24.  
    25. IAPManager: Begin Initialize
    26. IAPManager:InitProducts()
    27. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    28.  
    29. 2021-10-03 01:01:29.598548+0700 sniperzombies[2885:712402] UnityIAP: Requesting 66 products
    30. IAPManager: End Initialize
    31. IAPManager:InitProducts()
    32. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    33.  
    34. 2021-10-03 01:01:29.605811+0700 sniperzombies[2885:712402] UnityIAP: Requesting product data...
    35. 2021-10-03 01:02:04.607350+0700 sniperzombies[2885:712402] [BackgroundTask] Background Task 1 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
    And then I click buy:
    Code (CSharp):
    1. IAPManager: Start Buy sz.shop.gold.gp01
    2. IAPManager:BuyProductID(String, String)
    3. UnityEngine.Events.UnityAction:Invoke()
    4. UnityEngine.Events.UnityEvent:Invoke()
    5. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    6. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    7. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    8. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    9. UnityEngine.EventSystems.StandaloneInputModule:Process()
    10. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    11.  
    12. IAPManager: m_StoreController != null : False | m_StoreExtensionProvider != null : False
    13. IAPManager:IsInitialized()
    14. IAPManager:BuyProductID(String, String)
    15. UnityEngine.Events.UnityAction:Invoke()
    16. UnityEngine.Events.UnityEvent:Invoke()
    17. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    18. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    19. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    20. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    21. UnityEngine.EventSystems.StandaloneInputModule:Process()
    22. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    23.  
    24. IAPManager: BuyProductID FAIL. Not initialized. Reinit
    25. IAPManager:BuyProductID(String, String)
    26. UnityEngine.Events.UnityAction:Invoke()
    27. UnityEngine.Events.UnityEvent:Invoke()
    28. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    29. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    30. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    31. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    32. UnityEngine.EventSystems.StandaloneInputModule:Process()
    I post my code again:
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Purchasing;
    5. using System.Linq;
    6.  
    7. // Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.
    8. public class IAPManager : MonoBehaviour, IStoreListener
    9. {
    10.     public enum IAPInitStatus
    11.     {
    12.         None,
    13.         Successed,
    14.         Failed
    15.     }
    16.  
    17.     private static IAPManager _Instance;
    18.     public static IAPManager Instance
    19.     {
    20.         get
    21.         {
    22.             if (_Instance == null)
    23.             {
    24.                 GameObject gameObject = new GameObject("IAPManager");
    25.                 _Instance = gameObject.AddComponent<IAPManager>();
    26.             }
    27.             return _Instance;
    28.         }
    29.         set
    30.         {
    31.             _Instance = value;
    32.         }
    33.     }
    34.  
    35.     private IStoreController m_StoreController;          // The Unity Purchasing system.
    36.     private IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
    37.     private IAppleExtensions m_AppleExtensions;
    38.     private IGooglePlayStoreExtensions m_GooglePlayStoreExtensions;
    39.  
    40.     private IAPInitStatus m_IAPInitStatus = IAPInitStatus.None;
    41.     public IAPInitStatus Status
    42.     {
    43.         get
    44.         {
    45.             return m_IAPInitStatus;
    46.         }
    47.         set
    48.         {
    49.             m_IAPInitStatus = value;
    50.         }
    51.     }
    52.  
    53.     private void Start()
    54.     {
    55.         DontDestroyOnLoad(gameObject);
    56.     }
    57.  
    58.     private void Update()
    59.     {
    60.         //Debug.Log(IsInitialized());
    61.     }
    62.  
    63.     public void Init()
    64.     {
    65.         InitProducts();
    66.     }
    67.  
    68.     void InitProducts()
    69.     {
    70.         Debug.Log("IAPManager: Init product");
    71.  
    72.         m_IAPInitStatus = IAPInitStatus.None;
    73.  
    74.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    75.  
    76.         Debug.Log("IAPManager: Begin add product");
    77.         foreach (var iap in IAPProducts.ProductList)
    78.         {
    79.             string productid = iap.ID;
    80.             ProductType producttype = iap.Type;
    81.             builder.AddProduct(productid, producttype, new IDs() { { productid, AppleAppStore.Name }, { productid, GooglePlay.Name } });
    82.             //builder.AddProduct(productid, producttype, new IDs() {});
    83.         }
    84.         Debug.Log("IAPManager: End add product ");
    85.  
    86.         Debug.Log("IAPManager: Begin Initialize");
    87.         UnityPurchasing.Initialize(this, builder);
    88.         Debug.Log("IAPManager: End Initialize");
    89.     }
    90.  
    91.  
    92.     public bool IsInitialized()
    93.     {
    94.         Debug.Log("IAPManager: m_StoreController != null : " + ( m_StoreController != null ) + " | m_StoreExtensionProvider != null : " + ( m_StoreExtensionProvider != null ) );
    95.         // Only say we are initialized if both the Purchasing references are set.
    96.         return m_StoreController != null && m_StoreExtensionProvider != null;
    97.     }
    98.  
    99.     public void BuyProductID(string productId, String eventId = "")
    100.     {
    101.         Debug.Log("IAPManager: Start Buy " + productId);
    102.         // If Purchasing has been initialized ...
    103.         if (IsInitialized())
    104.         {
    105.             // ... look up the Product reference with the general product identifier and the Purchasing
    106.             // system's products collection.
    107.             Product product = m_StoreController.products.WithID(productId);
    108.  
    109.             // If the look up found a product for this device's store and that product is ready to be sold ...
    110.             if (product != null && product.availableToPurchase)
    111.             {
    112.                 m_StoreController.InitiatePurchase(product);
    113.             }
    114.             // Otherwise ...
    115.             else
    116.             {
    117.                 // ... report the product look-up failure situation
    118.                 Debug.Log("IAPManager: BuyProductID FAIL. Not purchasing product, either is not found or is not available for purchase");
    119.                 PopupManager.Instance.PopupOK.Show("Not purchasing product, either is not found or is not available for purchase.");
    120.             }
    121.         }
    122.         // Otherwise ...
    123.         else
    124.         {
    125.             // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
    126.             // retrying initiailization.
    127.             Debug.Log("IAPManager: BuyProductID FAIL. Not initialized. Reinit");
    128.             PopupManager.Instance.PopupOK.Show("Not initialized.");
    129.         }
    130.     }
    131.  
    132.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    133.     {
    134.         // Purchasing has succeeded initializing. Collect our Purchasing references.
    135.         Debug.Log("IAPManager: OnInitialized - PASS");
    136.  
    137.         // Overall Purchasing system, configured with products for this application.
    138.         m_StoreController = controller;
    139.         // Store specific subsystem, for accessing device-specific store features.
    140.         m_StoreExtensionProvider = extensions;
    141.  
    142.         m_AppleExtensions = extensions.GetExtension<IAppleExtensions>();
    143.         m_GooglePlayStoreExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
    144.  
    145.         // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature.
    146.         // On non-Apple platforms this will have no effect; OnDeferred will never be called.
    147.         m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred);
    148.  
    149.         m_IAPInitStatus = IAPInitStatus.Successed;
    150.  
    151.         Debug.Log(IsInitialized());
    152.     }
    153.  
    154.  
    155.     public void OnInitializeFailed(InitializationFailureReason error)
    156.     {
    157.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    158.         Debug.Log("IAPManager: OnInitializeFailed InitializationFailureReason:" + error);
    159.  
    160.         m_IAPInitStatus = IAPInitStatus.Failed;
    161.     }
    162.  
    163.  
    164.     public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    165.     {
    166.         Debug.Log("IAPManager: ProcessPurchase - ID: " + args.purchasedProduct.definition.id);
    167.         PopupManager.Instance.PopupOK.Show("Success!");
    168.         return PurchaseProcessingResult.Complete;
    169.     }
    170.  
    171.     public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    172.     {
    173.         // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing
    174.         // this reason with the user to guide their troubleshooting actions.
    175.         Debug.Log(string.Format("IAPManager: OnPurchaseFailed - FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
    176.         PopupManager.Instance.PopupOK.Show("Failed!\n" + failureReason);
    177.     }
    178.  
    179.     /// <summary>
    180.     /// iOS Specific.
    181.     /// This is called as part of Apple's 'Ask to buy' functionality,
    182.     /// when a purchase is requested by a minor and referred to a parent
    183.     /// for approval.
    184.     ///
    185.     /// When the purchase is approved or rejected, the normal purchase events
    186.     /// will fire.
    187.     /// </summary>
    188.     /// <param name="item">Item.</param>
    189.     private void OnDeferred(Product item)
    190.     {
    191.         Debug.Log("Purchase deferred: " + item.definition.id);
    192.     }
    193. }
    Do you need product info?
    I have created a new project and implemented these codes. Could I send you the source for reviewing?
     
    Last edited: Oct 2, 2021
  23. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The purchase error says IAP is not initialized. So this works on other versions of iOS, just not iOS 15? Where is the debug statement for OnInitialized or OnInitializedFailed? I'm not seeing PASS in your debug logs. Are you testing via TestFlight?
     
  24. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Yes!

    They are not callback. The console does not print any logs about them.

    I debug on Xcode 13.0 and macOS Big Sur 11.6.
     
    Last edited: Oct 4, 2021
  25. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I've tested on iOS 15 with the Sample IAP Project v2 without issue. We are not actively looking at this issue until we have more information and specific steps to reproduce. So you're claim is that OnInitialized or OnInitializedFailed are never called? I am not seeing that behavior and able to make purchases. I'm using the Sample IAP Project v2.
     
  26. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    I will try your Sample IAP Project.
    Thanks for your support.
     
  27. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D

    I don't know what is happening to me T_T
    I built your sample with my IAP product, and it still can't initialize.
    I just let you know. I will find out what my problem is.

    P/S: Sorry for my English.

    C3EBF7AC-C4A8-4511-9ADD-1F6CE518CEC5.jpeg Screenshot at Oct 05 00-15-37.png
     
  28. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please show it initializing on a working device, as you had mentioned. Also, try with only one product.
     
  29. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D,

    I have just run your sample on iPad 2 (iPadOS 12.2)
    And the result:

    Code (CSharp):
    1. 2021-10-05 02:07:29.086277+0700 SampleIAPProject[218:3488] UnityIAP UnityEarlyTransactionObserver: Created
    2. 2021-10-05 02:07:29.087858+0700 SampleIAPProject[218:3488] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    3. 2021-10-05 02:07:29.156631+0700 SampleIAPProject[218:3488] Built from '2020.3/release' branch, Version '2020.3.15f2 (6cf78cb77498)', Build type 'Release', Scripting Backend 'il2cpp'
    4. 2021-10-05 02:07:29.176170+0700 SampleIAPProject[218:3488] MemoryManager: Using 'Default' Allocator.
    5. -> applicationDidFinishLaunching()
    6. 2021-10-05 02:07:29.569580+0700 SampleIAPProject[218:3488] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    7. -> applicationDidBecomeActive()
    8. GfxDevice: creating device client; threaded=1
    9. Initializing Metal device caps: Apple A8X GPU
    10. Initialize engine version: 2020.3.15f2 (6cf78cb77498)
    11. UnloadTime: 0.469333 ms
    12. Starting Initialized...
    13. MyIAPManager:MyDebug(String)
    14. MyIAPManager:InitializePurchasing()
    15. UnityEngine.Events.UnityAction:Invoke()
    16. UnityEngine.Events.UnityEvent:Invoke()
    17. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    18. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    19. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    20. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    21. UnityEngine.EventSystems.StandaloneInputModule:Process()
    22.  
    23. 2021-10-05 02:07:37.545815+0700 SampleIAPProject[218:3488] UnityIAP: Requesting 66 products
    24. 2021-10-05 02:07:37.548063+0700 SampleIAPProject[218:3488] UnityIAP: Requesting product data...
    25. 2021-10-05 02:07:51.109496+0700 SampleIAPProject[218:3488] UnityIAP: Received 66 products
    26. OnInitialized: PASS
    27. MyIAPManager:MyDebug(String)
    28. MyIAPManager:OnInitialized(IStoreController, IExtensionProvider)
    29. UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    30. UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    31. UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    32. System.Action:Invoke()
    33. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    34.  
    35. 2021-10-05 02:07:51.427097+0700 SampleIAPProject[218:3488] UnityIAP: Add transaction observer
    36. 2021-10-05 02:07:51.427464+0700 SampleIAPProject[218:3488] UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    37. Purchasing product:sz.shop.gold.gp01
    38. MyIAPManager:MyDebug(String)
    39. MyIAPManager:BuyProductID(String)
    40. UnityEngine.Events.UnityAction:Invoke()
    41. UnityEngine.Events.UnityEvent:Invoke()
    42. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    43. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    44. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    45. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    46. UnityEngine.EventSystems.StandaloneInputModule:Process()
    47.  
    48. 2021-10-05 02:09:05.529333+0700 SampleIAPProject[218:3488] UnityIAP: PurchaseProduct: sz.shop.gold.gp01
    49. 2021-10-05 02:09:05.542412+0700 SampleIAPProject[218:3488] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
    50. 2021-10-05 02:09:05.545769+0700 SampleIAPProject[218:3488] [MC] Reading from public effective user settings.
    51. 2021-10-05 02:09:05.575184+0700 SampleIAPProject[218:3488] UnityIAP: UpdatedTransactions
    52. -> applicationWillResignActive()
    53. -> applicationDidBecomeActive()
    54. -> applicationWillResignActive()
    55. 2021-10-05 02:09:31.841670+0700 SampleIAPProject[218:3488] UnityIAP: UpdatedTransactions
    56. -> applicationDidBecomeActive()
    57. Error is The type initializer for 'UnityEngine.Purchasing.Security.GooglePlayTangle' threw an exception.
    58. MyIAPManager:MyDebug(String)
    59. MyIAPManager:ProcessPurchase(PurchaseEventArgs)
    60. UnityEngine.Purchasing.PurchasingManager:ProcessPurchaseIfNew(Product)
    61. UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    62. System.Action:Invoke()
    63. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    64.  
    65. ProcessPurchase: sz.shop.gold.gp01
    66. MyIAPManager:MyDebug(String)
    67. MyIAPManager:ProcessPurchase(PurchaseEventArgs)
    68. UnityEngine.Purchasing.PurchasingManager:ProcessPurchaseIfNew(Product)
    69. UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    70. System.Action:Invoke()
    71. UnityEngine.Purchasing.Extension.UnityUtil:Update()
    72.  
    73. 2021-10-05 02:09:40.993393+0700 SampleIAPProject[218:3488] UnityIAP: Finishing transaction 1000000887739677
    74.  
    IMG_1795.PNG IMG_1796.PNG
     
  30. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Looks good! So far, we have not been able to reproduce, but clearly you are. We need to reproduce here before we can work on a fix. All we can do at this point is to hope for additional reports that may better pinpoint the cause.
     
    Huy_Ng likes this.
  31. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Thanks, JeffDUnity3D.
    Meanwhile, I'll try to find a solution for my game.
    And there is new information I will let you know.
     
  32. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So just to be clear, I noticed the Sample IAP Project you showed, returned 66 products. The Sample only has 3. Did you create a new project, or import into an existing project, or just upgrade the Sample? Can you also try via TestFlight?
     
  33. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    I use your sample & replace your products by my products.
    Tomorrow, I will try via TestFlight and let you know later.
     
  34. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Just try one product in your test.
     
  35. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    I have already tried. Still not working on iOS 15.
     
  36. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    I have just tried again on iOS 15.0.1 with one product...
    Code (CSharp):
    1. Starting Initialized...
    2. MyIAPManager:MyDebug(String)
    3. MyIAPManager:InitializePurchasing()
    4. UnityEngine.Events.UnityAction:Invoke()
    5. UnityEngine.Events.UnityEvent:Invoke()
    6. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    7. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    8. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    9. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    10. UnityEngine.EventSystems.StandaloneInputModule:Process()
    11.  
    12. 2021-10-05 02:41:27.697220+0700 SampleIAPProject[1029:240412] UnityIAP: Requesting 1 products
    13. 2021-10-05 02:41:27.698079+0700 SampleIAPProject[1029:240412] UnityIAP: Requesting product data...
    14. 2021-10-05 02:42:02.700189+0700 SampleIAPProject[1029:240412] [BackgroundTask] Background Task 2 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
    15. BuyProductID FAIL. Not initialized.
    16. MyIAPManager:MyDebug(String)
    17. UnityEngine.Events.UnityAction:Invoke()
    18. UnityEngine.Events.UnityEvent:Invoke()
    19. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    20. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    21. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    22. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    23. UnityEngine.EventSystems.StandaloneInputModule:Process()
    24.  
    25.  
     
    JeffDUnity3D likes this.
  37. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Hi @JeffDUnity3D,

    I downgrade UnityIAP to version 2.2.2 in your sample, and then I get these logs as below (on iOS15):
    (Do you think the problem come from Xcode 13?)
    Code (CSharp):
    1. Starting Initialized...
    2. MyIAPManager:MyDebug(String)
    3. MyIAPManager:InitializePurchasing()
    4. UnityEngine.Events.UnityAction:Invoke()
    5. UnityEngine.Events.UnityEvent:Invoke()
    6. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    7. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    8. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    9. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    10. UnityEngine.EventSystems.StandaloneInputModule:Process()
    11.  
    12. (Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
    13.  
    14. 2021-10-08 01:42:50.246941+0700 sniperzombies[813:203920] UnityIAP: Requesting 66 products
    15. 2021-10-08 01:42:50.249036+0700 sniperzombies[813:203920] UnityIAP: Requesting product data...
    16. 2021-10-08 01:42:52.433681+0700 sniperzombies[813:204912] [tcp] tcp_output [C16.1.1:3] flags=[R.] seq=3364360710, ack=884585191, win=2060 state=CLOSED rcv_nxt=884585191, snd_una=3364360193
    17. 2021-10-08 01:42:52.438412+0700 sniperzombies[813:204912] Connection 16: received failure notification
    18. 2021-10-08 01:42:52.439967+0700 sniperzombies[813:204912] Connection 16: failed to connect 3:-9816, reason -1
    19. 2021-10-08 01:42:52.440222+0700 sniperzombies[813:204912] Connection 16: encountered error(3:-9816)
    20. 2021-10-08 01:43:02.668225+0700 sniperzombies[813:204967] [tcp] tcp_output [C17.1.1:3] flags=[R.] seq=123251153, ack=2843719821, win=2060 state=CLOSED rcv_nxt=2843719821, snd_una=123250636
    21. 2021-10-08 01:43:02.672091+0700 sniperzombies[813:204967] Connection 17: received failure notification
    22. 2021-10-08 01:43:02.672628+0700 sniperzombies[813:204967] Connection 17: failed to connect 3:-9816, reason -1
    23. 2021-10-08 01:43:02.672817+0700 sniperzombies[813:204967] Connection 17: encountered error(3:-9816)
    24. 2021-10-08 01:43:12.907653+0700 sniperzombies[813:205223] [tcp] tcp_output [C18.1.1:3] flags=[R.] seq=459592787, ack=1215578626, win=2060 state=CLOSED rcv_nxt=1215578626, snd_una=459592627
    25. 2021-10-08 01:43:12.911245+0700 sniperzombies[813:205223] Connection 18: received failure notification
    26. 2021-10-08 01:43:12.911812+0700 sniperzombies[813:205223] Connection 18: failed to connect 3:-9816, reason -1
    27. 2021-10-08 01:43:12.912050+0700 sniperzombies[813:205223] Connection 18: encountered error(3:-9816)
    28. 2021-10-08 01:43:12.916686+0700 sniperzombies[813:205223] Task <E112D358-E9CB-4D46-A7D7-3EAEAB4DDD90>.<6> HTTP load failed, 0/0 bytes (error code: -1200 [3:-9816])
    29. 2021-10-08 01:43:12.918253+0700 sniperzombies[813:204967] Task <E112D358-E9CB-4D46-A7D7-3EAEAB4DDD90>.<6> finished with error [-1200] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://cdp.cloud.unity3d.com/v1/events, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E112D358-E9CB-4D46-A7D7-3EAEAB4DDD90>.<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    30.     "LocalDataTask <E112D358-E9CB-4D46-A7D7-3EAEAB4DDD90>.<6>"
    31. ), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://cdp.cloud.unity3d.com/v1/events, NSUnderlyingError=0x283575ec0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9816, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9816}}, _kCFStreamErrorCodeKey=-9816}
    32. 2021-10-08 01:43:25.250785+0700 sniperzombies[813:203920] [BackgroundTask] Background Task 3 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
     
  38. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you got these logs via XCode? I just wanted to confirm. Why do you think it might XCode 13 related? I'm seeing a network error "NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made" Can you use a browser on the device and try to browse to https://cdp.cloud.unity3d.com/v1/events ? You should receive the message "Method Not Allowed" which is expected from a browser. Where are you located?
     
  39. Huy_Ng

    Huy_Ng

    Joined:
    Jul 28, 2019
    Posts:
    16
    Yes. I'm using XCode 13.

    I just suggest. Because I can't think of anything else.

    Screenshot_1.png

    Vietnam.
     
  40. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    As you can see, your device cannot reach the website. It looks to be blocked by your local network. You might try a VPN.