Search code examples
unity-game-enginestorekitprime31

Prime31's StoreKit Exception


I am trying to receive product's list using store kit, but I am getting an exception continuously:

Uncaught exception: NSInvalidArgumentException: *** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[4]

This is stack trace from console:

0   CoreFoundation                      0x2fa12feb <redacted> + 154
    1   libobjc.A.dylib                     0x3a1bfccf objc_exception_throw + 38
    2   CoreFoundation                      0x2f9514a3 <redacted> + 530
    3   CoreFoundation                      0x2f95126b <redacted> + 50
    4   ninjaworld                          0x016d09d4 +[StoreKitSerializationHelpers jsonStringFromProductArray:] + 1312
    5   ninjaworld                          0x016ceaf4 -[StoreKitManager productsRequest:didReceiveResponse:] + 532
    6   StoreKit                            0x321c4863 <redacted> + 466
    7   libdispatch.dylib                   0x3a6a7833 <redacted> + 10
    8   libdispatch.dylib                   0x3a6a781f <redacted> + 22
    9   libdispatch.dylib                   0x3a6a7777 <redacted> + 254
    10  CoreFoundation                      0x2f9dd8f1 <redacted> + 8
    11  CoreFoundation                      0x2f9dc1c5 <redacted> + 1300
    12  CoreFoundation                      0x2f946f4f CFRunLoopRunSpecific + 522
    13  CoreFoundation                      0x2f946d33 CFRunLoopRunInMode + 106
    14  GraphicsServices                    0x3484b663 GSEventRunModal + 138
    15  UIKit                               0x3229216d UIApplicationMain + 1136
    16  ninjaworld                          0x000dcb5c main + 288
    17  ninjaworld                          0x000dca38 start + 40

This exception occurs before the invoke of any callback method.

Product's list is retrieving successfully if I use native iOS code. There is some problem in plugin may be. Please guide me how I can I debug this code as Prime31 doesn't expose their code.

I enabled logs for Plugin. List of products is retrieved successfully. Exception is raised somewhere after that point.

LOG:

-[StoreKitManager requestProductData:]
2014-09-01 07:42:00.702 ninjaworld[2519:60b] SKProductsRequest sent with productIdentifiers: {(
    "com.company.coinpack1",
    "com.company.coinpack4",
    "com.company.coinpack3",
    "com.company.coinpack2",
    "com.company.coinpack5"
)}
2014-09-01 07:42:07.654 ninjaworld[2519:60b] -[StoreKitManager productsRequest:didReceiveResponse:]
2014-09-01 07:42:07.658 ninjaworld[2519:60b] response.products.count: 5
2014-09-01 07:42:07.661 ninjaworld[2519:60b] response.products: (
    "<SKProduct: 0x16df4ca0>",
    "<SKProduct: 0x16df4e10>",
    "<SKProduct: 0x16df5400>",
    "<SKProduct: 0x16df54a0>",
    "<SKProduct: 0x16df5670>"
)

//Exception raised after that

Unity Code (Showing only Relevant Code)

void Start () {

        productsIDs = new string[]
        {
            "com.company.coinpack1",
            "com.company.coinpack2",
            "com.company.coinpack3",
            "com.company.coinpack4",
            "com.company.coinpack5"


        };

        OnEnable ();
        StoreKitBinding.requestProductData(productsIDs);

    }

void OnEnable()
    {
        // Listens to all the StoreKit events. All event listeners MUST be removed before this object is disposed!
        StoreKitManager.transactionUpdatedEvent += transactionUpdatedEvent;
        //StoreKitManager.productPurchaseAwaitingConfirmationEvent += productPurchaseAwaitingConfirmationEvent;
        StoreKitManager.purchaseSuccessfulEvent += purchaseSuccessfulEvent;
        StoreKitManager.purchaseCancelledEvent += purchaseCancelledEvent;
        StoreKitManager.purchaseFailedEvent += purchaseFailedEvent;
        StoreKitManager.productListReceivedEvent += productListReceivedEvent;
        StoreKitManager.productListRequestFailedEvent += productListRequestFailedEvent;

        StoreKitBinding.enableHighDetailLogs (true);

//      StoreKitManager.restoreTransactionsFailedEvent += restoreTransactionsFailedEvent;
//      StoreKitManager.restoreTransactionsFinishedEvent += restoreTransactionsFinishedEvent;
    }

void productListReceivedEvent( List<StoreKitProduct> productList )
    {
        if (productList == null) {

            print("**** It's null!!!!");
            return;
                }

        Debug.Log( "productListReceivedEvent. total products received: " + productList.Count );

        // print the products to the console
        foreach( StoreKitProduct product in productList )
            Debug.Log( product.ToString() + "\n" );
    }


    void productListRequestFailedEvent( string error )
    {
        Debug.Log( "productListRequestFailedEvent: " + error );
    }

Solution

  • My code was fine. Issue was because of my Jailbreak device. I tested my code on some other device, and it worked well.