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.

[Solved] NoProductsAvailable

Discussion in 'Unity IAP' started by Beniamino, Dec 22, 2015.

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

    Beniamino

    Joined:
    Jul 25, 2015
    Posts:
    17
    Is there a reason to get "NoProductsAvailable" error when I do have a product set to Active in the correct App? It's been a while since I started trying to get the IAP services working, but I took some time off of that when I heard it was going to be easier in the newest patch.
     
  2. mpinol

    mpinol

    Unity Technologies

    Joined:
    Jul 29, 2015
    Posts:
    317
    Hi @Beniamino,

    Can you confirm that the Initialize callback gave a success status flag? Are you having this issue on Android?
     
  3. Beniamino

    Beniamino

    Joined:
    Jul 25, 2015
    Posts:
    17
    On the PC I'm getting that OnInitialized is called, followed by my output message "added non-consumable" which is called at the appropriate time. On Android it skips to "added non-consumable" and then I have my "oninit fail" message I wrote to print when OnInitializeFailed is called. That's followed by NoProductsAvailable. Sorry, does that answer the question about the callback?
     
  4. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    Are you initializing IAP twice? You should only do so once. What does "added non-consumable" do in the OnInitialized method? You should configure all your products prior to initialisation.
     
  5. Beniamino

    Beniamino

    Joined:
    Jul 25, 2015
    Posts:
    17
    Thanks. I'm not sure what you mean by configuring them before initialization. Here's what I have. I copied it from a tutorial but added some things. The AddText() method is my own so I can have debug on the screen even when on Android.

    void Start () {
    if (m_StoreController == null) {
    InitializePurchasing ();
    AddText ("start");
    } else {
    print ("Store controller is not null.");
    }
    }

    public void InitializePurchasing () {
    if (IsInitialized ()) {
    AddText ("Initialized already.");
    return;
    }
    var builder = ConfigurationBuilder.Instance (StandardPurchasingModule.Instance ());
    builder.AddProduct (kProductIDNonConsumable, ProductType.NonConsumable,
    new IDs (){{ kProductNameAppleNonConsumable, AppleAppStore.Name },{ kProductNameGooglePlayNonConsumable,
    GooglePlay.Name },});
    UnityPurchasing.Initialize (this, builder);
    AddText ("Added non-consumable.");
    }
     
    hansadler likes this.
  6. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    294
    I'm getting the same error doing the same procedure! I'm trying this without a test app (in other words it's not up on Google Play, not even an alpha version, this shouldn't be required right?).

    EDIT:
    Okay I just tried using one of our existing apps in-app products and it seems to work now. That should be more clear in the documentation. If we add products (even if they doesn't exist on Google Play) they shouldn't cause initialization to fail.
     
    Last edited: Jan 7, 2016
  7. jimihay

    jimihay

    Joined:
    Mar 19, 2012
    Posts:
    15
    Hi, I'm receiving the same error with the Google Play store and cannot figure out why. I'm switching over from using Prime31's plugins so I know my products work. Only change I made was to add in references to UnityEngine.Purchasing, implement the new interface, and add this as found in the docs.

    ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    builder.AddProduct("knownproductid", ProductType.NonConsumable);

    #if UNITY_ANDROID
    builder.Configure<IGooglePlayConfiguration>().SetPublicKey(Global.AndroidPublicKey);
    #endif

    UnityPurchasing.Initialize(this, builder);


    OnInitializeFailed is getting called next with the error of "NoProductsAvailable"

    I'm also noticing a warning when I connect to adb

    Warning: Unknown product identifier: {0}: com.mycompany.game.knownproductid

    I change the ID's here, but really I'm using the exact same info that I was using before. The product ID that is printed to the console matches, case and everything, to what I have setup in Google play as well.

    Any ideas? Is there something I might have overlooked regarding the Android manifest file?

    Thanks!

    EDIT:
    Figured it out. I was miss led by the warning in the console. Although it was printing the correct product id, it was not using the correct id when communicating with Google.

    My app's bundle id is com.MyCompany.Game, but my products are com.mycompany.game.whatever (all lower case as required by Google)

    I changed the addproduct call to give the full id. Note that the documentation here http://docs.unity3d.com/Manual/UnityIAPDefiningProducts.html does not show that you can supply the full id, but it does work.

    builder.AddProduct("knownproductid", ProductType.NonConsumable, new IDs
    {
    {"com.mycompany.game.knownproductid", GooglePlay.Name}
    });
     
    Last edited: Jan 8, 2016
    Novack likes this.
  8. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    Glad you figured it out!
     
  9. lbddk

    lbddk

    Joined:
    Nov 1, 2013
    Posts:
    5
    In Android , Is there a way to add new product after Initialized?
    or i can Initialize again ?
     
  10. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    In Unity 5.4 you can use IStoreController.FetchAdditionalProducts to retrieve more products incrementally.
     
Thread Status:
Not open for further replies.