Search Unity

[Solved] Initialize and AddProduct at realtime ?

Discussion in 'Unity IAP' started by bao-tran, Dec 28, 2015.

Thread Status:
Not open for further replies.
  1. bao-tran

    bao-tran

    Joined:
    Dec 9, 2015
    Posts:
    5
    Hello, my game is an online game and I want to fetch all my product ids from my server. So I create full tier ready on the store. In game, can I recreate list product by code at real time?

    This is my implement code

    Code (CSharp):
    1.     public void CreateProducts()
    2.     {
    3.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    4.  
    5.         for (int i = 0; i < CDataManager.Instance.ListProductInfo.Count; i++)
    6.         {
    7.             JProductInfo storePackInfo = CDataManager.Instance.ListProductInfo[i];
    8.  
    9.             builder.AddProduct(storePackInfo.ProductID, ProductType.Consumable, new IDs()
    10.             {
    11.                 { storePackInfo.ProductID, AppleAppStore.Name },
    12.                 { storePackInfo.ProductID, GooglePlay.Name }, });
    13.         }
    14.  
    15.         UnityPurchasing.Initialize(this, builder);
    16.     }
    I use it again and again when my data is fetched complete
     
  2. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    You should fetch all your products in advance and initialise Unity IAP with all of them at once.
     
Thread Status:
Not open for further replies.