2017-08-28 7 views
0

お願いします。UnityのGoogleストアでIABを正しくセットアップするにはどうすればいいですか?

誰かがiBoxを請求してアンドロイドゲームのユニティに使用していますか?はいの場合は、私の知識を共有してください。

私はゲーム内でオープンiabをユニティエンジンと統合しようとしました。しかし、私はより明確に説明するチュートリアルは見つかりません。私はここのYouTubeでチュートリアルを見つける:open iab tutorialしかし、それは英語ではありません。私は彼の言うことを理解していない。

もし私がそれを設定していれば誰かが私のコードを見てもらえますか? 以下は私のリンクのサンプルコードです:

My Sample Code // 注:サンプルコードはもう存在しない場合は、単にスクリプトを使用して、私のポスト正解を参照してください。

上記のリンクは14日間で有効期限が切れています。まだ答えがなければ私は更新します。

私の質問ここでは、以下の

が正しいかどうか?ここでは、以下の

const string SKU1 = "com.games.games1"; 
const string SKU2 = "com.games.games1"; 
const string SKU3 = "com.games.games1"; 
const string SKU4 = "com.games.games1"; 
const string SKU5 = "com.games.games1"; 
const string SKU6 = "com.games.games1"; 

は正しいですか?ここでは、以下の

OpenIAB.mapSku(SKU1, OpenIAB_Android.STORE_GOOGLE, "pack1gt"); 
    OpenIAB.mapSku(SKU2, OpenIAB_Android.STORE_GOOGLE, "pack2gt"); 
    OpenIAB.mapSku(SKU3, OpenIAB_Android.STORE_GOOGLE, "pack3gt"); 
    OpenIAB.mapSku(SKU4, OpenIAB_Android.STORE_GOOGLE, "estateagenbundle"); 
    OpenIAB.mapSku(SKU5, OpenIAB_Android.STORE_GOOGLE, "landlordbundle"); 
    OpenIAB.mapSku(SKU6, OpenIAB_Android.STORE_GOOGLE, "miraclebundle"); 

は正しいですか?成功各製品を認識するための方法をここで

public void pack1gt() { 
    OpenIAB.purchaseProduct(SKU1); 
} 

public void pack2gt() { 
    OpenIAB.purchaseProduct(SKU2); 
} 

public void pack3gt() { 
    OpenIAB.purchaseProduct(SKU3); 
} 

private void purchaseSucceededEvent(Purchase purchase) 
{ 
    Debug.Log("purchaseSucceededEvent: " + purchase); 
    Debug.Log ("purchasesuccess: " + purchase.AppstoreName); 
    Debug.Log ("purchasesuccess: " + purchase.Sku); 
    _label = _label + "\n" + "PURCHASED:" + purchase.ToString(); 
    OpenIAB.consumeProduct(purchase); 
    Debug.Log (_label); 
    if (purchase.Sku == "pack1gt") { 
     sp.pack1gt(); 
    } else if (purchase.Sku == "pack2gt") { 
     sp.pack2gt(); 
    } else if (purchase.Sku == "pack3gt") { 
     sp.pack3gt(); 
    } else if (purchase.Sku == "estateagenbundle") { 
     sp.EstateAgentBundle(); 
    } else if (purchase.Sku == "landlordbundle") { 
     sp.LandLordBundle(); 
    } else if (purchase.Sku == "miraclebundle") { 
     sp.MiracleBundle(); 
    } 

} 

のIPアップの設定方法上記の私の質問が正しいかどうか?そうでない場合は、正しく設定するための解決策は何ですか?

答えて

0

最後に、私は1週間の実験の後、自分で解決策を見つけました。私は試しましたsdkbox iapopeniabです。 SDKBOX iapは動作しませんが、open iabが働いています。

以下は、Googleストアのiabを開く方法の詳細を設定する方法です。

以下は正しい完全なスクリプトです。私は手がかりについてコメントしました。あなたのAndroidManifest.xml修正

using UnityEngine; 
using OnePF; 
using System.Collections.Generic; 

public class IAPScript : MonoBehaviour { 

    //Start Product Name Mapping ---- This your mapping product, recommend use a name as the product id at google store 

    const string SKU1 = "pack1gt"; 
    const string SKU2 = "pack2gt"; 
    const string SKU3 = "pack3gt"; 
    const string SKU4 = "estateagenbundle"; 
    const string SKU5 = "landlordbundle"; 
    const string SKU6 = "miraclebundle"; 

    //End Product Name Mapping ----- 

    // Start Leave As It ----- 

    string _label = ""; 
    bool _isInitialized = false; 
    Inventory _inventory = null; 

    void Awake() { 
     OpenIABEventManager.billingSupportedEvent += billingSupportedEvent; 
     OpenIABEventManager.billingNotSupportedEvent += billingNotSupportedEvent; 
     OpenIABEventManager.queryInventorySucceededEvent += queryInventorySucceededEvent; 
     OpenIABEventManager.queryInventoryFailedEvent += queryInventoryFailedEvent; 
     OpenIABEventManager.purchaseSucceededEvent += purchaseSucceededEvent; 
     OpenIABEventManager.purchaseFailedEvent += purchaseFailedEvent; 
     OpenIABEventManager.consumePurchaseSucceededEvent += consumePurchaseSucceededEvent; 
     OpenIABEventManager.consumePurchaseFailedEvent += consumePurchaseFailedEvent; 
    } 

    // End Leave As It ----- 

    private void Start() 
    { 
     // Map skus for different stores  
     OpenIAB.mapSku(SKU1, OpenIAB_Android.STORE_GOOGLE, "pack1gt"); 
     OpenIAB.mapSku(SKU2, OpenIAB_Android.STORE_GOOGLE, "pack2gt"); 
     OpenIAB.mapSku(SKU3, OpenIAB_Android.STORE_GOOGLE, "pack3gt"); 
     OpenIAB.mapSku(SKU4, OpenIAB_Android.STORE_GOOGLE, "estateagenbundle"); 
     OpenIAB.mapSku(SKU5, OpenIAB_Android.STORE_GOOGLE, "landlordbundle"); 
     OpenIAB.mapSku(SKU6, OpenIAB_Android.STORE_GOOGLE, "miraclebundle"); 

     Initialized(); 
    } 

    //Start Initialized Method ---- 
    void Initialized() { 

     // Application public key (Find it at google console Service and API) 
     var googlePublicKey = "your current public key"; 

     var options = new Options(); 
     options.checkInventoryTimeoutMs = Options.INVENTORY_CHECK_TIMEOUT_MS * 2; 
     options.discoveryTimeoutMs = Options.DISCOVER_TIMEOUT_MS * 2; 
     options.checkInventory = false; 
     options.verifyMode = OptionsVerifyMode.VERIFY_SKIP; 
     options.prefferedStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE }; 
     options.availableStoreNames = new string[] { OpenIAB_Android.STORE_GOOGLE }; 
     options.storeKeys = new Dictionary<string, string> { {OpenIAB_Android.STORE_GOOGLE, googlePublicKey} }; 
    options.storeSearchStrategy = SearchStrategy.INSTALLER_THEN_BEST_FIT; 

     // Transmit options and start the service 
     OpenIAB.init(options); 

     if (!_isInitialized) 
      return; 

    } 
    //End Initialized Method ---- 


    public void Query_Inventory() { 
     OpenIAB.queryInventory(new string[] { SKU1,SKU2,SKU3,SKU4,SKU5,SKU6 }); 
    } 

    //Start Each Call Product Method ---- 

    public void pack1gt() { 
    // Buy Product SKU1 (pack1gt) 
     OpenIAB.purchaseProduct(SKU1); 
    } 

    public void pack2gt() { 
    // Buy Product SKU2 (pack2gt) 
     OpenIAB.purchaseProduct(SKU2); 
    } 

    public void pack3gt() { 
    // Buy Product SKU3 (pack3gt) 
     OpenIAB.purchaseProduct(SKU3); 
    } 

    public void estateagenbundle() { 
    // Buy Product SKU4 (estateagenbundle) 
     OpenIAB.purchaseProduct(SKU4); 
    } 

    public void landlordbundle() { 
    // Buy Product SKU5 (landlordbundle) 
     OpenIAB.purchaseProduct(SKU5); 
    } 

    public void miraclebundle() { 
    // Buy Product SKU6 (miraclebundle) 
     OpenIAB.purchaseProduct(SKU6); 
    } 

    //End Each Call Product Method ---- 


    // Start Leave As It Except you Know what you have modified --- 
    private void billingSupportedEvent() 
    { 
     _isInitialized = true; 
     Debug.Log("billingSupportedEvent"); 
     _label = _label + "\n" + "billingSupportedEvent"; 
    } 

    private void billingNotSupportedEvent(string error) 
    { 
     Debug.Log("billingNotSupportedEvent: " + error); 
     _label = _label + "\n" + "billingNotSupportedEvent"; 
    } 

    private void queryInventorySucceededEvent(Inventory inventory) 
    { 
     Debug.Log("queryInventorySucceededEvent: " + inventory); 
     if (inventory != null) 
     { 
      _label = inventory.ToString(); 
      _inventory = inventory; 
      List<Purchase> prods = inventory.GetAllPurchases(); 

      foreach(Purchase p in prods) OpenIAB.consumeProduct(p); 
      Debug.Log (_label); 
     } 
    } 

    private void queryInventoryFailedEvent(string error) 
    { 
     Debug.Log("queryInventoryFailedEvent: " + error); 
     _label = error; 
     Debug.Log (_label); 
    } 

    // End Leave As It Except you Know what you have modified --- 

    //Start Success When Purchased ---- 

    private void purchaseSucceededEvent(Purchase purchase) 
    { 
     Debug.Log("purchaseSucceededEvent: " + purchase); 
     Debug.Log ("purchasesuccess: " + purchase.AppstoreName); 
     Debug.Log ("purchasesuccess: " + purchase.Sku); 
     _label = _label + "\n" + "PURCHASED:" + purchase.ToString(); 

    // Here Consume The Product ---- 
    OpenIAB.consumeProduct(purchase); 
     Debug.Log (_label); 

    // Here How to check product your buy at google store 
    // Give a case and call the method or make your one 
     if (purchase.Sku == "pack1gt") { 
      sp.pack1gt(); 
     } else if (purchase.Sku == "pack2gt") { 
      sp.pack2gt(); 
     } else if (purchase.Sku == "pack3gt") { 
      sp.pack3gt(); 
     } else if (purchase.Sku == "estateagenbundle") { 
      sp.EstateAgentBundle(); 
     } else if (purchase.Sku == "landlordbundle") { 
      sp.LandLordBundle(); 
     } else if (purchase.Sku == "miraclebundle") { 
      sp.MiracleBundle(); 
     } 

    } 

    //End Success When Purchased ---- 

    //Start Failed When Purchased ---- 

    private void purchaseFailedEvent(int errorCode, string errorMessage) 
    { 
     Debug.Log("purchaseFailedEvent: " + errorMessage); 
     _label = _label + "\n" + "Purchase Failed: " + errorMessage; 

     Debug.Log (_label); 
     sp.FailedPurchase(); 
    } 

    //End Failed When Purchased ----- 

    // Start Leave As It Except you Know what you have modified --- 

    private void consumePurchaseSucceededEvent(Purchase purchase) 
    { 
     Debug.Log("consumePurchaseSucceededEvent: " + purchase); 
     _label = _label + "\n" + "CONSUMED: " + purchase.ToString(); 
     Debug.Log (_label); 
    } 

    private void consumePurchaseFailedEvent(string error) 
    { 
     Debug.Log("consumePurchaseFailedEvent: " + error); 
     _label = _label + "\n" + "Consume Failed: " + error; 
     Debug.Log (_label); 
    } 

    // End Leave As It Except you Know what you have modified --- 
} 

追加:

<uses-permission android:name="android.permission.INTERNET" /> 
<application ... > 
     <activity android:name="org.onepf.openiab.UnityProxyActivity" 
       android:launchMode="singleTask" 
       android:label="@string/app_name" 
       android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"> 
    </activity> 
</application> 
<uses-feature android:name="android.hardware.telephony" android:required="false" /> 
<uses-permission android:name="com.android.vending.BILLING" /> 
<uses-permission android:name="org.onepf.openiab.permission.BILLING" /> 
<permission android:name="com.tmoney.vending.INBILLING"/> 

すべてです。

関連する問題