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

Resolved Unity In-App Purchasing requires Unity Gaming Services to have been initialized before use

Discussion in 'Unity IAP' started by Sparticus, Aug 31, 2022.

Thread Status:
Not open for further replies.
  1. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    Yesterday I was forced to upgrade my Unity version to the latest version. In doing so, now when I load up Unity, I get the following warning :

    Unity IAP: Unity In-App Purchasing requires Unity Gaming Services to have been initialized before use.


    I have read the documentation provided here : https://docs.unity.com/ugs-overview/services-core-api.html#InitializationExample

    and I am not quite sure where to add this code. I do not use the codeless IAP version (I wrote code to use the
    UnityEngine.Purchasing library).

    In my IAPManager class I wrote, I added the code mentioned in the documentation (adding it to the start method).

    I still get the warning. I even tried adding it to the very first class that gets loaded when my app starts, I still get the warning.

    Is there a trick to getting this to work?

    Thanks!
     
    SirhotBay likes this.
  2. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    Actually, the full error I am getting is :


    Unity IAP: Unity In-App Purchasing requires Unity Gaming Services to have been initialized before use.
    - Find out how to initialize Unity Gaming Services by following the documentation https://docs.unity.com/ugs-overview/services-core-api.html#InitializationExample
    or download the 06 Initialize Gaming Services sample from Package Manager > In-App Purchasing > Samples.
    - If you are using the codeless API, you may want to enable the enable Unity Gaming Services automatic initialization by checking the Automatically initialize Unity Gaming Services checkbox at the bottom of the IAP Catalog window
    UnityEngine.Purchasing.CodelessIAPStoreListener:InitializeCodelessPurchasingOnLoad () (at Library/PackageCache/com.unity.purchasing@4.3.0/Runtime/Codeless/CodelessIAPStoreListener.cs:52)


    The error is on line 52 in this file : references Library/PackageCache/com.unity.purchasing@4.3.0/Runtime/Codeless/CodelessIAPStoreListener.cs:52

    I am not using the "codeless iap version".... why is this code executing? I'm guessing by upgrading my unity it added this code by default. How do I disable this codeless version? I already have a coded iap version working.
    upload_2022-8-31_12-16-28.png
     
    SirhotBay likes this.
  3. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    Ok, solved my own problem. I'll post the answer here in case it helps anyone else.

    I found a file in Resources/IAPProductCatalog.json (which I don't know where it came from as I never made it) the following configuration :


    "enableCodelessAutoInitialization":true


    setting it to false made the issue go away
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    ilmario, Petr777 and akhror_unity like this.
  5. Sparticus

    Sparticus

    Joined:
    Mar 15, 2014
    Posts:
    149
    Thanks man. I appreciate the info :)
     
  6. BIMG

    BIMG

    Joined:
    Oct 1, 2014
    Posts:
    16
    Hi,
    I have "enableCodelessAutoInitialization":false, but still got warning.

    Unity 2020.3.38 inApp 4.3.0.
     
  7. Michael_Gilbert_11

    Michael_Gilbert_11

    Joined:
    Dec 27, 2017
    Posts:
    2
    Same here, I'm still getting the warning with "enableCodelessAutoInitialization" set to false. InApp 4.5.0
     
  8. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @BIMG , @Michael_Gilbert_11,

    It's likely normal that you will still get the warning. Those checkboxes are for Codeless IAP, and don't exempt any user from getting the warning if they don't initialize the UGS services manually.

    If you don't want to opt in to the UGS services you won't need to enable it. You can then ignore the warning if you don't intend to use it. See this FAQ for information: https://forum.unity.com/threads/faq-for-iap-4-2-and-adoption-of-ugs-analytics.1327011/

    If you are initializing it, and you still get the warning, it could be a race condition because you initialize UnityPurchasing before calling the services InitializeAsync. If that's the case, IAP will try to use these services before they're ready. Don't worry too much, we enqueue any events that would use them and they'll be dequeued once we get the Services Initialize callback.

    I don't have much context with regards to your projects. If you are unsure about something, please give me more details such as:

    • Whether you are or are not using Codeless IAP
    • Whether you intend to use UGS services
    • When you call UnityServices.InitializeAsync vs UnityPurchasing.Initialize
    • Any strange behaviours you may be encountering (besides the warning)
     
  9. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    422
    Can i use IAP with UnityServices.InitializeAsync call, but without UGS subscription?
     
  10. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @justtime,

    Yes you can. If you need if for any other subscription-free UGS service, ex: Cloud Diagnostics, Remote config, go ahead.

    Also the Transaction and TransactionFailed analytics results are supposed to be visible for free with an unpaid signup.

    There is currently no IAP feature that requires a UGS Subscription, but we facilitate a few services automatically.
     
    justtime likes this.
  11. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    172
    This thread is now closed. Feel free to reach out via a new thread if you encounter further issue.
    Thanks!
     
Thread Status:
Not open for further replies.