How do you Initialize UDP sandbox test mode ?

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 ?

1 Like

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.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

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/com.unity.purchasing.udp@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.

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:

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

I tried adding

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

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.

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.

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

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:
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?

![6250956--688944--FullSettings-1.png|1824x1763](upload://vISAPyjdeIPQRJ2XuK0nq0cDHLk.png)

I tried upgrading the project to unity 2020.1.3, still getting the error
IAP OnInitializeFailed InitializationFailureReason:AppNotKnown

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

1 Like

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) :
using UnityEngine;
using UnityEngine.UDP;

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);
    }
}
  1. 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.
# Instantiate the listener
IInitListener listener = new InitListener();
# Use the listener to initialize the UDP stuff
StoreService.Initialize(listener);
  1. 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!

8 Likes

Be sure not to attach the “InitListener” script to any gameobjects or you will get an error!

2 Likes

you can not add a non-monobehavior class to an object

2 Likes

I am implementing UDP via Unity IAP and when I try to select “Window → Unity IAP → Android → Target Unity Distribution Portal” I am getting the following response:

6357294--707145--Screenshot 2020-09-28 at 5.16.44 PM.png

And when I am trying to import UDP package from package manager then getting the response as shown in the attached screenshot. Don’t know what to do next


Please uninstall the UDP package you installed before via Packman and then install the recommended one.

To uninstall the UDP package via Packman: Window → Package Manager → Remove the UDP package.
6360756--707754--upload_2020-9-29_14-40-43.png

Is this a Unity Pro thing?
It simply doesn´t work in Unity 2018.4.27.

UDP is installed, with settings and a UDP Sandbox Test Account.

Had to add MonoBehaviour to the InitListener class, and add it to a gameobject to GetComponent(), instead of new InitListener().

After that the Debug.Log(“Initialization succeeded”); runs, but the Distribution Portal still says UDP Initialization Not detected.

Same result when running the compiled apk on a device.

You need to run the apk on the device. Do you see the UDP login window and log in to the sandbox test account?

There are no UDP login window on the device either. It´s the same in Unity 2019.4.

The InitListener.OnInitialized(UserInfo userInfo) runs in the Editor but the userInfo is null in the callback.

Can you tell please can we test in-apps (UDP package) in editor?