Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Other How do you Initialize UDP sandbox test mode ?

Discussion in 'Unity Distribution Portal (UDP)' started by OscarLeif, Aug 22, 2020.

  1. OscarLeif

    OscarLeif

    Joined:
    Jul 17, 2016
    Posts:
    16
    I read all the steps to follow

    Your game must clear a basic UDP Sandbox test before its first release. UDP will verify that your game initializes and purchases IAP items properly before letting you release your first revision and move to the submission stages.

    How to complete this step?Collapse
    • First, be sure to create UDP Sandbox Test accounts. You can do this in the section directly below, or in the Unity Editor. (Done)

    • Run your UDP APK on an emulator or a real Android device. (Done)
    • Use your UDP Sandbox Test account credentials to log in. (wait how do I do that ?)
    • Test your game, and make at least one IAP transaction. It's a sandbox environment, no real money is involved!

    • During the course of the above steps, your game will call the Initialize() and Purchase() methods.

    • You will see the results during your sandbox testing, and UDP will also capture the results on its back-end.
    The most confuse step is when running on a real device, also the test account I mean I have to use my Unity account here ?
    I'm confused in this step. Also what about when my game don't use IAP ?
    Probably not necessary but do I really need IAP to use UDP ?
     
  2. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    Yess! I wanted to ask the exact same question!
    I'm using unity IAP, and selected Unity IAP->Android->"target Unity Distribution Portal (UDP)"
    I uploaded the latest apk binary to the UDP portal

    However, it's this step that confuses me:

    Use your UDP Sandbox Test account credentials to log in.


    When launch the app nothing happens, and in the debug console I just get a message that IAP is not initialized.
    The code I'm using was tested for google play and ios iaps and there it worked

    I added my gmail email that device uses to the sandbox accounts in the UDP dashboard.
    How do I get this magical UDP sandbox login screen?

    08-24 16:43:13.953 25037-25056/? I/Unity: Initializing UnityPurchasing via Codeless IAP
    08-24 16:43:13.963 25037-25056/? I/Unity: UnityIAP Version: 1.23.5
    08-24 16:43:14.113 25037-25056/? I/Unity: IAP OnInitializeFailed InitializationFailureReason:AppNotKnown


    I've been comparing all the ID's in the UDP settings and in the dashboard, all seem to match up ( unity project ID, client ID, Client key, etc), but for whatever reason the "game ID" is different, however there is no way to change it in either unity or the dashboard
     
    Last edited: Aug 24, 2020
  3. OscarLeif

    OscarLeif

    Joined:
    Jul 17, 2016
    Posts:
    16
    Ok I finally know why the reason of the sanbox email.
    You need to initialize the UDP package via script.

    https://docs.unity3d.com/Packages/c...@1.2/manual/Using_the_UDP_package_detail.html



    public class InitListener : IInitListener
    {
    public void OnInitialized(UserInfo userInfo)
    {
    Debug.Log("Initialization succeeded");
    // You can call the QueryInventory method here
    // to check whether there are purchases that haven’t be consumed.
    }

    public void OnInitializeFailed(string message)
    {
    Debug.Log("Initialization failed: " + message);
    }
    }


    After this the game will show up a new view to write your email and password that you manually set in the UDP console (the website).

    Too bad App Gallery will demand to be a premium App or must have IAP to publis via UDP.
    So after completed all the steps I cannot publish my app because of that.
    In this case I cannot upload my game because it's not a premium app or don't have IAP.
     
  4. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    This is really strange - the manual clearly states to use one implementation, either Unity's IAP or the UDP code but not to mix them. I tried adding your code and also

    StoreService.Initialize(this);


    However, now I'm getting this error when running the app on the device:

     AndroidJavaException: java.lang.ClassNotFoundException: com.unity.udp.sdk.ChannelService


    I tried importing/installing UDP from both the package manager and IAP store, and it gives this error.

    I tried adding
            <meta-data
    android:name="UDP_SDK_VERSION"
    android:value="2.0.0" />
    <meta-data
    android:name="UDP_SDK_DIST"
    android:value="unityiap" />


    but that didn't help - that just gave the error that this was already added somewhere
     
  5. OscarLeif

    OscarLeif

    Joined:
    Jul 17, 2016
    Posts:
    16
    That error is because you forgot some android library. Maybe you should install the IAP plugins from the asset store that also install the UDP plugin.
     
  6. Unity-ChiBoon

    Unity-ChiBoon

    Unity Technologies

    Joined:
    Jan 18, 2017
    Posts:
    10
    Hi yuriythebest, you should be only using either the UDP SDK or Unity IAP package. If you are using Unity IAP package currently, please update to the latest version and reinstall again. It should guide you through to install the UDP package along the update.
     
  7. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    Hi!
    If I did try using the Unity IAP code previously but got this error:
    InitializationFailureReason:AppNotKnown


    Hi Unity - Chiboon!

    1. Is Unity IAP for UDP currently actually supported? When using Unity IAP, should the "log into sandbox" dialog actually appear or is that only for the UDP SDK?
    Use your UDP Sandbox Test account credentials to log in.


    2. Should the UDP SDK be present, but not used, when using Unity IAP?

    3. Should be added to the androidmanifest in the case of using UDP SDK?

    4. I use unity 2018.4.10f and the latest version of Unity IAP / UDP SDK ( I was trying both since neither worked), is this version of unity supported? I do get the option of "target UDP" in the unity IAP settings
     
  8. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    Okay, trying it again, the steps I did in my project was:
    1) Delete all unity IAP/Unity SDK stuff
    2) Added Unity IAP through services. It complained that stuff was missing so had to add unity IAP in the package manager as well.
    3). Now getting this error:
    Assembly 'Assets/Plugins/UnityPurchasing/Bin/Editor.dll' will not be loaded due to errors:
    Unable to resolve reference 'UDP'. Is the assembly missing or incompatible with the current platform?
    Reference validation can be disabled in the Plugin Inspector.

    4) because of #3, I had to install UDP: I clicked the imported UDP unitypackage that appeared when I imported unity IAP from services
    note: I had to install by clicking the packages, since the Install UDP dialog kept freezing

    Result1: When I set Unity IAP’s Target to Google Play I get the error NoProductsAvailable - fair enough, since I added them specifically for the UDP Version
    Result2: When I set Unity IAP’s Target to UDP, I get

    IAP OnInitializeFailed InitializationFailureReason:AppNotKnown


    I rechecked all the settings and compared the UDP settings in the dashboard and project,
    and the Game ID is different, all other things are the same, and there is no way to change the Game ID. Could this issue be because of the Game ID, and if so how do I change it?
     

    Attached Files:

    Last edited: Aug 27, 2020
  9. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    I tried upgrading the project to unity 2020.1.3, still getting the error
    IAP OnInitializeFailed InitializationFailureReason:AppNotKnown
     
  10. yuriythebest

    yuriythebest

    Joined:
    Nov 21, 2009
    Posts:
    1,029
    Okay, Small update if anyone has this same issue: I tried creating an empty project in 2020.1.3 and just installed unity IAP/configured the UDP settings inside unity, added a test iap from inside unity and now the UDP sandbox screen magically appears!! I'm able to login and make the test purchase ( it's only visible in the android studio logcat but returns purchase succeeded)

    EDIT: To anyone else having this issue, I was able to solve this by creating an empty project and setting everything up as described above, then go to my old project and export everything as a unitypackage, and import into the new project.

    The UDP Sandbox login thing is real, and should appear at the very start of your app if everything works. I tested it using Unity IAP

    Also not sure if it somehow "helped", but I also changed my iaps from "myiapname" to "com.myapp.myiapname" but not sure if this was critical
     
    Last edited: Aug 29, 2020
  11. PixelsJunkie

    PixelsJunkie

    Joined:
    Jul 15, 2020
    Posts:
    3
    Well, after struggling with this for a while because the documentation wasnt very helpful (unclear, typos in the code etc). Here is the solution of "Initializing the UDP SDK" for newbies :

    1. Create a new C# file (the file name is not important) and put the following code inside (the code from the documentation contains some errors that I fixed btw) :
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.UDP;
    4.  
    5. public class InitListener : IInitListener
    6. {
    7.     public void OnInitialized(UserInfo userInfo)
    8.     {
    9.         Debug.Log("Initialization succeeded");
    10.         // You can call the QueryInventory method here
    11.         // to check whether there are purchases that haven’t be consumed.    
    12.     }
    13.  
    14.     public void OnInitializeFailed(string message)
    15.     {
    16.         Debug.Log("Initialization failed: " + message);
    17.     }
    18. }
    2. Now go to your game main file and add using UnityEngine.UDP; at the top then put the following code in the Awake() or Start() method. In my case, I have a GameManager file that handle the game cycle, so I put this code inside its Awake() method.
    Code (CSharp):
    1.  
    2. # Instantiate the listener
    3. IInitListener listener = new InitListener();
    4. # Use the listener to initialize the UDP stuff
    5. StoreService.Initialize(listener);
    6.  
    3. Finally, build your project and run it on a real device (emulators may work but not the unity simulator). when the game launches you will be prompted by the UDP authentication dialog. Use the Sand box test account(s) to login and voilà!

    Cheers!
     
    Last edited: Sep 15, 2020 at 2:37 AM
  12. jacksonacademyashmore

    jacksonacademyashmore

    Joined:
    Jun 21, 2017
    Posts:
    5
    Be sure not to attach the "InitListener" script to any gameobjects or you will get an error!
     
unityunity