Search Unity

[1.20.0][iOS Android] UnityPurchasing.Initialize without internet lacks callback.

Discussion in 'Unity IAP' started by Jasper-Chimp, Oct 2, 2018.

  1. Jasper-Chimp

    Jasper-Chimp

    Joined:
    Sep 4, 2018
    Posts:
    7
    Hello,

    I've implemented Unity IAP in our project and I noticed that calling UnityPurchasing.Initialize while the device is lacking an internet connection (e.g. airplane mode) never results in either IStoreListener.OnInitialized or IStoreListener.OnInitializeFailed being called.

    As far as I know I can't find any documentation on internet requirements for Unity IAP, however it makes sense to me that if internet is required, some form of time-out should trigger the failure callback after a while.

    Is this by design? If not, I've attached the code file I've written that implements the IStoreListener interface and calls the UnityPurchasing.Initialize function.

    Extra details:
    Unity version: 2017.4.7f1
    Unity IAP version: 1.20.0
    Platforms reproduced: iOS app store & Android Google Play Store
     

    Attached Files:

    Last edited: Oct 2, 2018
  2. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,

    Unity IAP will retry if there is no network connected.
    The retry delay would start from 5000ms, and it'll be doubled at next round. The max is 300000ms.
    Here is a sample log.
    I'm sorry that you can't control the initialization step or make the time shorter currently.
    Internet is required for IAP initialization. And time-out will not trigger the failure callback, Unity IAP will just keep retrying.
     
  3. Jasper-Chimp

    Jasper-Chimp

    Joined:
    Sep 4, 2018
    Posts:
    7
    Hello unityjingyao,

    Thanks for letting us know, so in this case we can just start initialization ASAP and inform the user if store initialization is taking longer than expected.
     
  4. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi,
    You can also check the Internet connection before initializing Unity IAP.
    Then inform the user or continue initialization.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I should add that the IAP team has been made aware of this behavior, and is considering appropriate approaches to handle no/limited network access.
     
    MAttila likes this.
  6. Dazo1985

    Dazo1985

    Joined:
    Mar 13, 2019
    Posts:
    26
    Right now i do.

    on BuyProductID() and
    RestorePurchases()

    if (IsInitialized()) is false
    InitializePurchasing();

    This should be fine or do I overlook something here?
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your logic looks correct. What is your issue? Are you testing without the Internet?
     
  8. Dazo1985

    Dazo1985

    Joined:
    Mar 13, 2019
    Posts:
    26
    Hi Jeff

    No real issue :)
    (i havent fully tested it yet)

    I just wanted to be covered if the user does not have internet while the appstart
    but later on has internet
    and presses on the purchase button,
    that in this moment the purchase system has been initialized so the player can
    purchase withouth issue.

    Maybe unitys auto retry is good enough.
    (not really in depth tested it yet)

    But to be sure to get an initializing attempt as close to the players purchase attempt as possible I added the logic above.

    Just wanted to get sure this will not cause any issues preemptively.
     
    Last edited: Apr 9, 2019
  9. chin13577

    chin13577

    Joined:
    May 8, 2017
    Posts:
    17
    well I have a same issue
    when I Initialize UnityPurchasing
    Code (CSharp):
    1.  UnityPurchasing.Initialize
    but

    After I've Removed "Google Account" from my android device setting and Added "Google Account" again.
    It's worked after that.
     

    Attached Files:

  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Notice the error:6 in the logs, this is returned by Google if there is a problem with the account. We are still trying to narrow down what triggers this condition though. I can generate the error by changing the Google password online, but not yet on an unlocked device. But others are seeing the error even without a password update.