Search Unity

[Closed] IAP: Amazon, Google and Unity IAP

Discussion in 'Unity IAP' started by Zocker1996, Mar 10, 2016.

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

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    Hi,

    I'm new to In App Purchases and currently working on a cross platform app that I want to publish for iOS, Windows 10 Universall and Android.
    I was very excited to learn that the Unity IAP Service is supporting these platforms. My only concerne is Android: I want to publish on Google Play and the Amazon Store.

    So I started looking around for a good way to do this. The first step was therefor to understand the prequisitions for Amazon and Google IAP.
    As far as I unterstood, the only prequisition is, that the matching Stores (Google Play and Amazon store) need to be installed on the device.
    Therefor I can imagine 4 scenarios:

    1) The Android device hasnt installed any store and installed my app on some other (maybe even illegal) way.
    This means that the user cant use IAP.

    2) The Android devices has installed Google Play but not the Amazon store. This is the simplest case since everything works with Unity IAP.

    3) Only the Amazon store is installed (since its a Fire Device or something similar). Unity IAP shouldnt work here (or?).

    4) BOTH, Amazon and Google Play are installed on the device. I want the user to choose which to us. Or is this bad practice?


    So a general question is now, what happens with Unity IAP if the Goolge Play store isn't installed? Does it not show up or simply crash?
    Shall I check before even showing Unity IAP if Google Play is installed?
    Is there any smart methode to find out which store (and therefor which IAP methode) is installed on the device?

    Maybe the best way is to make two different builds for Amazon and Google Play?

    Are my thoughts correct or am I missing some points?

    I'm glad for any suggestions and comments!
     
  2. nicholasr

    nicholasr

    Unity Technologies

    Joined:
    Aug 15, 2015
    Posts:
    119
    @Zocker1996 Yes that reasoning is what we settled on: the best way is to make two different builds for Amazon and Google Play. To differentiate the stores for our upcoming Amazon & Samsung support we plan on adding menu items which will set (override the default GooglePlay) Android store for the next build, until you upgrade Unity IAP plugins at which point it'll default again.

    For discussion purposes, if you side-load an application you wrote into which you had integrated Unity IAP, onto an Android device which had no branding / no store whatsoever, I expect our implementation would look for and fail gracefully when connecting to the _backing store service_ (whichever service IAP decided was the "best" service for the runtime environment). Behavior on "No Store" Android devices is undefined and not supported.

    Did I miss answering any of your questions?
     
  3. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    Thank you! I guess I understand now ;)

    So could you say when this next Unity IAP supporting Amazon will arive? I mean I could try getting my head arround Amazon but if you say that you will support it the next few weeks I dont take effort to implement this seperatly.
     
    nicholasr likes this.
  4. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    316
    Hi @Zocker1996,

    We can't give any specific release information but I can tell you it will be quite soon. :)
     
    nicholasr likes this.
  5. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
    I'm glad to hear that :)

    Not sure if I should open an other theard so I'm asking here:

    Unity IAP also enables Unity Analytics. I played around with Analytics and Costum Events and so on. I found out that I can filter user platform with the segment builder for every event I can recognize.

    Unity Analytics Transaction method is automaticly called from Unity IAP if the user buys something.
    I would be very interessted to know from which store the user buys this (and by the way for every other [custom] event, too), meaning that when Amazon IAP will be supported by Unity the segment builder cant tell me from which store the events are coming. Should I start using a custom event, or will this feature be added to Unity Analytics?
     
  6. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    316
    Hi @Zocker1996,

    The ability to drill down past platform to app store is not something we have at the moment, but it certainly sounds like a really great idea! I have brought up your suggestion with my team, but it would be really helpful if you submitted this idea on our feedback page. We use the feedback page to find out what our users want to see in the dashboard, and what ideas are the most popular, we then use this information when deciding what features to work on implementing. Here is the link: https://feedback.unity3d.com/forums...f8=✓&status=0&category=analytics&view=hottest
     
  7. Zocker1996

    Zocker1996

    Joined:
    Jan 12, 2015
    Posts:
    20
  8. Anisoropos

    Anisoropos

    Joined:
    Jul 30, 2012
    Posts:
    92
    @nicholasr I've written a helper method to let you figure out programmatically during runtime which store your app came from. It currently supports Google Play, Amazon & Samsung Store but you could extend it to cover other stores as well.

    If you incorporated something like that in the IAP plugin you'd save us the trouble of building once for every store, which is both error prone (using the wrong configuration) and unnecessary. Plus it could be used for other things, like figuring out where to deep-link when you direct users to rate your app.

    Code (CSharp):
    1.  
    2.     private static AndroidJavaObject Android_getPackageManager()
    3.     {
    4.         AndroidJavaObject pM = null;
    5.  
    6. #if UNITY_ANDROID
    7.         if (!Application.isEditor)
    8.         {
    9.             AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    10.             AndroidJavaObject currentActivity = jc.GetStatic<AndroidJavaObject>("currentActivity");
    11.             // int flag = new AndroidJavaClass("android.content.pm.PackageManager").GetStatic<int>("GET_META_DATA");
    12.             pM = currentActivity.Call<AndroidJavaObject>("getPackageManager");
    13.         }
    14. #endif
    15.         return pM;
    16.     }
    17.  
    18.     /// <summary>
    19.     /// Where did this app come from? (Market)
    20.     /// </summary>
    21.     public static AndroidMarketPlace Android_getMarketPlace()
    22.     {
    23.         // Setting installer name when developing
    24.         /*
    25.         http://pixplicity.com/setting-install-vendor-debug-app/
    26.         adb push C:/app.apk /sdcard/app.apk
    27.         adb shell pm install -i "com.android.vending" -r /sdcard/app.apk
    28.         adb shell rm /sdcard/app.apk
    29.         adb shell pm uninstall com.mycompany.mygame
    30.         */
    31.  
    32.         AndroidMarketPlace source = AndroidMarketPlace.Unknown;
    33.         string installerPackageName = "";
    34.  
    35. #if UNITY_ANDROID
    36.         if (!Application.isEditor)
    37.         {
    38.             string packageName = Application.bundleIdentifier;
    39.  
    40.             // Application.bundleIdentifier
    41.             AndroidJavaObject pm = Android_getPackageManager();
    42.             installerPackageName = pm.Call<string>("getInstallerPackageName", packageName);
    43.             if (installerPackageName == null)
    44.                 installerPackageName = "";
    45.         }
    46. #endif
    47.  
    48.         if (installerPackageName.CompareTo("") != 0)
    49.         {
    50.             Debug_OnGUI_AddMessage(installerPackageName, 10);
    51.  
    52.             string processedPackageName = installerPackageName.RemoveSpaces();
    53.  
    54.             Debug_OnGUI_AddMessage(processedPackageName, 10);
    55.  
    56.             // Differentiate based on name
    57.             // http://stackoverflow.com/questions/17629787/how-android-app-can-detect-what-store-installed-it
    58.  
    59.             // Samsung contains android in the name
    60.             if (processedPackageName.ContainsInvariant("samsung"))
    61.                 source = AndroidMarketPlace.SamsungStore;
    62.             else if (processedPackageName.ContainsInvariant("amazon"))
    63.                 source = AndroidMarketPlace.Amazon;
    64.             else if (processedPackageName.ContainsInvariant("android"))
    65.                 source = AndroidMarketPlace.GooglePlay;
    66.  
    67.             Debug_OnGUI_AddMessage(source.ToString());
    68.         }
    69.         else
    70.             Debug_OnGUI_AddMessage("Couldn't get installer package name", 10);
    71.  
    72.         return source;
    73.     }
     
    breban1, nicholasr and erika_d like this.
  9. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    We will add an overload to the StandardPurchasingModule factory that lets you specify the desired android store.
     
  10. Anisoropos

    Anisoropos

    Joined:
    Jul 30, 2012
    Posts:
    92
    That's already in place, all I'm saying is that you can do that automatically for three of the most major stores (Google Play, Amazon, Samsung). Having to build the same apk three times is a mood killer :p
     
    breban1 likes this.
  11. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    131
    I know this thread is old, but I thought I'd let you know that I totally agree that something like this within Unity would be VERY helpful.

    @Anisoropos I'm going to use your code snippet and see how it goes, I really don't like the idea of 2 builds for Android (Google Play/Amazon), that's just asking for user error.
     
    Anisoropos likes this.
  12. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    230
    Is there a way to validate receipts within unity code for Amazon?

    There is the security thing for Google/IOS but there isnt one for Amazon.
     
    Last edited: Feb 3, 2017
    breban1 likes this.
  13. ap-unity

    ap-unity

    Unity Technologies

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