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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

can I defer purchase initialisation shouldAddStorePayment

Discussion in 'Unity IAP' started by BrianND, Jan 3, 2018.

  1. BrianND

    BrianND

    Joined:
    May 14, 2015
    Posts:
    79
    In UnityEarlyTransactionObserver.mm

    Code (CSharp):
    1.  
    2.    if (self.readyToReceiveTransactionUpdates) {
    3.        return YES;
    4.    } else {
    5.        if (m_QueuedPayments == nil)
    6.            m_QueuedPayments = [[NSMutableSet alloc] init];
    7.        [m_QueuedPayments addObject:payment];
    8.        return NO;
    9.    }
    I noticed that readyToReceiveTransactionUpdates is only false on MAC platform. Is there a way we can set this to be configurable? I would like to defer the purchase only when my app is ready. I don't want an IAP purchase window to pop up in the middle of them playing or during certain events.

    I saw some other forums related to this but I'm not sure if they are just deferring the post processing of a purchases. I want to actually defer the purchase window.

    Thanks
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @BrianND Your app should be able to handle a purchase event at any time. Keep in mind that you can perform IAP initialization at any time, but it is generally best to initialize IAP as early as possible.
     
  3. BrianND

    BrianND

    Joined:
    May 14, 2015
    Posts:
    79
    Is this now supported via
    IAppleConfiguration.SetApplePromotionalPurchaseInterceptorCallback?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @BrianND Can you provide the documentation that you are referring to?
     
  5. BrianND

    BrianND

    Joined:
    May 14, 2015
    Posts:
    79
    @JeffDUnity3D
    https://docs.unity3d.com/Manual/UnityIAPiOSMAS.html

    under
    Intercepting Apple promotional purchases

    Code (CSharp):
    1. private void OnPromotionalPurchase(Product item) {
    2.     Debug.Log("Attempted promotional purchase: " + item.definition.id);
    3.     // Promotional purchase has been detected.
    4.     // Handle this event by, e.g. presenting a parental gate.
    5.     // Here, for demonstration purposes only, we will wait five seconds before continuing
    6.     // the purchase.
    7.     StartCoroutine(ContinuePromotionalPurchases());
    8. }
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, you can handle the message in a coroutine.