Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKProductsRequest crashing app at startup with iOS 7.0.3

Tags:

ios

crash

startup

Reports of our app crashing started flooding in last night. Many users who upgraded to 7.0.3 had the app crash at startup. Analyzing the itunes crash logs it was due to the app getting killed for taking too long to startup. Apparently the call to check for available in-app purchases is what was causing the crash. We removed all in-app purchases from sale and now users are reporting that the app is now working.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 

// earlier stuff...
    [self requestProductData]; // ask for in-app purchase localized prices/names
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; // process any   pending transactions

// more stuff...
}

- (void) requestProductData
{
    NSMutableSet * prodSet = [[[NSMutableSet alloc] initWithCapacity:10] autorelease];

    StoreItem * curStoreItem;
    for(int j=0; j<[storeArr count]; j++) {
        curStoreItem = [storeArr objectAtIndex:j];
        [prodSet addObject:curStoreItem.productID];
    }


    SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:prodSet];
    request.delegate = self;
    [request start];
}

In didFinishLaunchingWithOptions, we make the call to request product data. Do we need to be doing this in another thread? Anyone else having this issue?

like image 615
ladfoo Avatar asked Nov 11 '22 19:11

ladfoo


1 Answers

We solved this in two ways, addressing the immediate live app crashing and then actually addressing the coding error that triggered it.

The iOS 7.0.3 update added a latency to the call to apple servers which return in-app product data. Since we were making the product request call from didFinishLaunching our app was being killed for not starting up quickly enough.

To address the live app crashing we temporarily removed all in app purchases for the app from sale. Meanwhile we moved the product data request to just prior to presenting the in-app storefront - the correct programmatic solution, as suggested by maddy.

like image 159
ladfoo Avatar answered Nov 15 '22 06:11

ladfoo