2017-08-28 3 views
0

Brauchen Sie Hilfe bitte.Wie installiere ich IAB im Unity Google Store richtig?

Verwendet jemand open iab für die Abrechnung Android and Games Einheit? Wenn ja, bitte teilen Sie mir Ihr Wissen mit.

Ich habe versucht, den offenen iab in meinem Spiel mit Unity-Engine integriert. Aber ich finde kein Tutorial, das deutlicher erklärt. Ich finde das Tutorial bei Youtube hier: open iab tutorial Aber es ist nicht in Englisch. Ich verstehe nicht, was er sagt.

Kann jemand meinen Code sehen, wenn ich ihn richtig eingestellt habe? Unten ist mein Link Beispielcode:

My Sample Code // Hinweis: Wenn der Beispielcode nicht mehr existiert nur meine Post richtige Antwort mit Skript sehen.

Link oben abgelaufen in 14 Tagen. Ich werde aktualisieren, wenn immer noch nicht antworten.

Meine Frage

Hier unten korrekt ist oder nicht?

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"; 

Hier unten korrekt ist oder nicht?

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"); 

Hier unten korrekt ist oder nicht?

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

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

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

Hier ist, wie jedes Produkt zu erkennen, wenn der Erfolg?

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(); 
    } 

} 

Mein Obige Frage, wie ip bis setzen ist richtig oder nicht? Wenn nicht, was ist die Lösung, um es richtig einzurichten?

Antwort

0

Endlich fand ich selbst eine Lösung nach einer Woche Experiment in App-Kauf in Einheit. Ich habe versucht sdkbox iap und openiab. SDKBOX iap funktioniert nicht aber öffnen iab gearbeitet.

Unten, wie mehr Details öffnen Sie öffnen iab für Google Store.

Unten korrektes vollständiges Skript. Ich habe zur Kenntnis genommen.

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

AndroidManifest.xml Modified.

Anzahl:

<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"/> 

Das ist alles.

Verwandte Themen