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. Unity announces intent to join forces with ironSource. Learn more in our blog post.
    Dismiss Notice

[Solved] Unity IAP Select store at runtime

Discussion in 'Unity IAP' started by Wadjey, Sep 13, 2016.

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

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Hi,
    I'm encountering an issue with the latest Unity IAP v1.8.1, It's always showing the Google Play IAP dialog instead the Amazon or Samsung Galaxy ones when these platforms are selected.

    I initialized Unity IAP like this:

    Code (CSharp):
    1.         var storeModule = StandardPurchasingModule.Instance();
    2.         if (Application.platform == RuntimePlatform.Android)
    3.         {
    4.             if (MySelectedPlatform.Andoid == PlayStore)
    5.             {
    6.                 storeModule = StandardPurchasingModule.Instance(AndroidStore.GooglePlay);
    7.             }
    8.             else if (MySelectedPlatform.Andoid == Amazon)
    9.             {
    10.                 storeModule = StandardPurchasingModule.Instance(AndroidStore.AmazonAppStore);
    11.             }
    12.             else if (MySelectedPlatform.Andoid == Samsung)
    13.             {
    14.                 storeModule = StandardPurchasingModule.Instance(AndroidStore.SamsungApps);
    15.             }
    16.         }
    17.         ConfigurationBuilder builder = ConfigurationBuilder.Instance(storeModule);
    18.  
    19.         builder.AddProduct(iap.id, ProductType.Consumable, new IDs() {
    20.                 { iap.skuApple, AppleAppStore.Name},
    21.                 { iap.skuGooglePlay, GooglePlay.Name},
    22.                 { iap.skuAmazon, AmazonApps.Name}
    23.             });
    24.         UnityPurchasing.Initialize(this, builder);
    I selected Windows -> Unity IAP -> Android -> Select store at runtime.

    And when I build I set the correct platform to be taken in account by Unity IAP.

    Now that my app is released for GPlay, Amazon and Samsung, when user click on IAP purchase button, it always show the Google Play IAP dialog for all platforms instead of the Amazon and Samsung ones for these respective platforms!
     
    anucha122606 likes this.
  2. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    @erika_d @jayr Can you please look into this issue?
     
  3. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,490
    Hi @Wajdik,

    Looking at your code, it seems like you are initializing the instance of the module multiple times (Line 1 and then again in the if statements). I would try removing the first line and only initializing once you know what store you are using.

    Also, would you be able to provide the code you are using to determine what Android platform the app is using? Are you using something like is mentioned in these stackoverflow threads:
    https://stackoverflow.com/questions...on-is-installed-from-google-play-or-side-load
    http://stackoverflow.com/questions/...as-been-downloaded-from-google-play-or-amazon

    The option to select stores at runtime has been causing some issues for users submitting to the app stores, so we are re-evaluating that as an option.

    As for now, I would try removing the multiple initialization and maybe look into how you are determining the platform.
     
    lifeisfunxyz, Wadjey and erika_d like this.
  4. Wadjey

    Wadjey

    Joined:
    Feb 4, 2015
    Posts:
    244
    Hi,
    Thanks for your help, it's working for Amazon now, I'll try later with Samsung.
    I'm using an Enumerator with Android platforms names, and I set the target platform manually (from a list of my target platform in the inspector) before building, as my game has some specific behaviors for each platform. And the new feature "Select store at runtime" is very helpful for me, in the past I need to select my targeted platform two times (in my list in the inspector and also for Unity IAP), and this was causing problems as sometimes I forget to select the correct Unity IAP target platform!
    Now I have to select the target Android platform only one time from my Android platforms list and all is OK :)
     
    erika_d likes this.
Thread Status:
Not open for further replies.
unityunity