Search Unity

How to get Unity IAP version programmatically

Discussion in 'Unity IAP' started by Wadjey, Apr 30, 2019.

  1. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Hi,
    Is it possible to get Unity IAP version programmatically?
    I want to include the Unity IAP version into the logs but I can't find a way to retrieve it programmatically!
     
    Last edited: Apr 30, 2019
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The version information is already written to the logs.
     
  3. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Which logs? I can't figure out how to access to it!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  5. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    When you build the app, you certainly know the IAP version then. You could just include that information in a define. Why do you need to get it programmatically?
     
  7. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    To avoid hard coding it, because when it's hard-coded there is a chance to miss updating it when I update UnityIAP.
    I thinks it will be useful if you provide something like Application.unityVersion for UnityIAP
     
    Suduckgames likes this.
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thank you for the suggestion
     
    Wadjey likes this.
  9. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    What you are looking for is:

    UnityEngine.Purchasing.StandardPurchasingModule.k_PackageVersion
     
    Lurendium likes this.
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I'm curious as to why you need the IAP version in the app at runtime?
     
  11. Lurendium

    Lurendium

    Joined:
    Nov 25, 2016
    Posts:
    8
    Wow, thanks! this is exactly what I needed!
     
  12. AakashDP

    AakashDP

    Joined:
    Nov 22, 2016
    Posts:
    21
    @JeffDUnity3D its very useful for checking/keeping track of which Unity IAP version is in a live app or is being used across various teams.

    Where I work, we have created a "module" out of UnityIAP for our teams to simply drag and drop into their project without having to implement all the features of UnityIAP by themselves. Since the UnityIAP plugin lives in the Assets folder and can easily be replaced by anyone, this api useful for keeping track of the version without needing to looking through the project.