SKProductsRequest crashing app at startup with iOS 7.0.3

旧时模样 提交于 2019-12-12 11:12:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19710264/skproductsrequest-crashing-app-at-startup-with-ios-7-0-3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!