Search Unity

[Solved] Set Android IAP target on rumtime

Discussion in 'Unity IAP' started by illuminat, Oct 11, 2016.

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

    illuminat

    Joined:
    Jul 2, 2014
    Posts:
    40
    Hi,

    I can't use UnityPurchasingEditor.TargetAndroidStore on runtime ('the name does not exist in the current context') which seems logical.

    However is it possible to set the Android IAP target on runtime or in a postbuild script? I would need that so I can set two different Unity Cloud Build targets for google and amazon based on the same project.

    Thanks for hints
     
    daniellopez7323 likes this.
  2. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    Hi @illuminat,

    Yes, you can select an Android store at runtime. There is a forum thread with an example implementation:
    https://forum.unity3d.com/threads/unity-iap-select-store-at-runtime.430882/

    First, in the Editor, you would choose Window -> Unity IAP -> Android -> Select store at runtime. And then in the Initialization of your IAP code, you would choose your store.

    The key piece of code is here:
    Code (CSharp):
    1.  
    2. storeModule = StandardPurchasingModule.Instance(AndroidStore.GooglePlay);
    3. ConfigurationBuilder builder = ConfigurationBuilder.Instance(storeModule);
    4.  
    Currently, the options are AndroidStore.GooglePlay, AndroidStore.AmazonAppStore, and AndroidStore.SamsungApps.
     
  3. illuminat

    illuminat

    Joined:
    Jul 2, 2014
    Posts:
    40
    thank you!
     
  4. TomFerrer

    TomFerrer

    Joined:
    Jun 21, 2017
    Posts:
    1
    I know this is an old post but how would I know if I was on an amazon phone or a google play phone?
     
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
Thread Status:
Not open for further replies.