onepf / OpenIAB

Open In-App Billing for Google Play, SlideMe, Amazon Store, Nokia Store, Samsung Apps, Yandex.Store, Appland, Aptoide, AppMall and Fortumo.
http://onepf.org/openiab/
Apache License 2.0
476 stars 171 forks source link

PaymentQueue:updateTransactions Crash on iOS #404

Closed ghost closed 9 years ago

ghost commented 9 years ago

I am trying to implement the Unity OpenIAB for Android and iOS. When testing on the Android, there were no issues. When I tested it for iOS, it crashed. It is crashing in (void)paymentQueue:(SKPaymentQueue )queue updatedTransactions:(NSArray )transactions. The transaction.transactionState == SKPaymentTransactionStateFailed. The transaction.error == NULL. This null appears to be what is throwing the error.

Here is a sample of my code that uses OpenIAB. Am I doing anything wrong in my code?

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

private void OnDisable()
{

    OpenIABEventManager.billingSupportedEvent -= billingSupportedEvent;
    OpenIABEventManager.billingNotSupportedEvent -= billingNotSupportedEvent;
    OpenIABEventManager.queryInventorySucceededEvent -= queryInventorySucceededEvent;
    OpenIABEventManager.queryInventoryFailedEvent -= queryInventoryFailedEvent;
    OpenIABEventManager.purchaseSucceededEvent -= purchaseSucceededEvent;
    OpenIABEventManager.purchaseFailedEvent -= purchaseFailedEvent;
    OpenIABEventManager.consumePurchaseSucceededEvent -= consumePurchaseSucceededEvent;
    OpenIABEventManager.consumePurchaseFailedEvent -= consumePurchaseFailedEvent;
}

private void Start()
{
    //Google Play
    OpenIAB.mapSku(SKU_ADS, OpenIAB_Android.STORE_GOOGLE, "remove_ads");
    OpenIAB.mapSku(SKU_50, OpenIAB_Android.STORE_GOOGLE, "_50");
    OpenIAB.mapSku(SKU_300, OpenIAB_Android.STORE_GOOGLE, "_300");
    OpenIAB.mapSku(SKU__1000, OpenIAB_Android.STORE_GOOGLE, "_1000");

    //IOS
    OpenIAB.mapSku(SKU_ADS, OpenIAB_iOS.STORE, "remove_ads");
    OpenIAB.mapSku(SKU_50, OpenIAB_iOS.STORE, "_50");
    OpenIAB.mapSku(SKU_300, OpenIAB_iOS.STORE, "_300");
    OpenIAB.mapSku(SKU_1000, OpenIAB_iOS.STORE, "_1000");

    InitializeIAB();
}

public void InitializeIAB(){

    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, OpenIAB_iOS.STORE};
    options.storeKeys.Add(OpenIAB_Android.STORE_GOOGLE, publicKey_Android);

    OpenIAB.init(options);

}

private void billingSupportedEvent()
{
    _isInitialized = true;
    Debug.Log("billingSupportedEvent");
    OpenIAB.queryInventory(new string[]{SKU_ADS, SKU_50, SKU_300, SKU_1000});
}

private void queryInventorySucceededEvent(Inventory inventory)
{
    if (inventory != null){
        Purchase removeAdsPurchase = inventory.GetPurchase(SKU_ADS);
                    .............................
        Purchase 50Purchase = inventory.GetPurchase(SKU_50);
        ............................
        Purchase 300Purchase = inventory.GetPurchase(SKU_300);
        .............................
        Purchase 1000Purchase = inventory.GetPurchase(SKU_1000);
                    ............................
    }
}

private void queryInventoryFailedEvent(string error)
{
    Debug.Log("queryInventoryFailedEvent: " + error);
}
GrimReio commented 9 years ago

Hello! Could you please try to build from dev branch? I think, this issue was fixed.

ghost commented 9 years ago

Looking at your document to build the plugin says 1)Get Gradle 2) Have JDK 1.6 or greater installed 3) Have JAVA_HOME environment variable set

I get a build failure. "A problem occurred configuring project :Unity Plugin. SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable."

From your description on how to build, it doesn't work. Are you able to provide me a copy of a build?

On Wed, Dec 3, 2014 at 5:56 AM, GrimReio notifications@github.com wrote:

Hello! Could you please try to build from dev branch? I think, this issue was fixed.

— Reply to this email directly or view it on GitHub https://github.com/onepf/OpenIAB/issues/404#issuecomment-65402712.

ghost commented 9 years ago

Would release 0.9.81 have this fix in it? https://github.com/onepf/OpenIAB/releases

ghost commented 9 years ago

I downloaded release 0.9.81, and it seems to have fixed my problem.