gpt4 book ai didi

ios - 有超出允许时间的事件断言 - 仅限 iPhone 5S,适用于 iPhone 5、4s 和 4

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:41:09 25 4
gpt4 key购买 nike

我收到以下应用程序的崩溃报告,该应用程序在后台与 NSURLconnection 进行后台通信,超时为 7 秒:

Incident Identifier: 3C862AC5-4226-461B-ACC8-6F080D2FDFDB
CrashReporter Key: 119b92a02f2002d19cf9f0b80d48362ac24a5d3e
Hardware Model: iPhone6,2
Process: xxx [1971]
Path: /var/mobile/Applications/33D1EAC9-8D24-4E40-805B-BD7C4FCD96FD/xxx.app/xxx
Identifier: com.xx.xxx
Version: 1.0.0 (1.0.0)
Code Type: ARM (Native)
Parent Process: launchd [1]

Date/Time: 2013-10-30 19:50:38.812 +1000
OS Version: iOS 7.0.3 (11B511)
Report Version: 104

Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 2

Application Specific Information:
xxx[1971] has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x17046ad40> identifier: Called by xxx, from unknown method process: xxx[1971] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1971 preventSuspend preventIdleSleep preventSuspendOnSleep
)}

Elapsed total CPU time (seconds): 0.440 (user 0.440, system 0.000), 4% CPU
Elapsed application CPU time (seconds): 0.000, 0% CPU

尝试使用以下代码片段时会发生这种情况:

+(NSURLRequest*)updateLocation4SampleRequest_withUserId:(NSString*)userId userAPIToken:(NSString*)userAPIToken p1:(CLLocation*)p1 p2:(CLLocation*)p2 p3:(CLLocation*)p3 p4:(CLLocation*)p4 accuracy:(CLLocationAccuracy)accuracy
{
// return [NSURLRequest requestWithURL: [[NSURL alloc] initWithString:[[NSString stringWithFormat: updateLocation4SampleRequestURL, OTNRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];

NSString *post = [NSString stringWithFormat: updateLocation4SampleRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy];

NSLog(@"%@",post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [[NSURL alloc] initWithString:OTNRequestURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:7];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
[request setHTTPBody:postData];

return request;
}

以及调用它并启动异步请求的函数。

// start the Link Maker search
NSURLRequest* request = [OTNUtil updateLocation4SampleRequest_withUserId:userId userAPIToken:user_api_token p1:p1 p2:p2 p3:p3 p4:p4 accuracy:OTNDataManager.app.currentLocation.horizontalAccuracy];
NSLog(@"%@, (UPDATELOCATION) user id: %@",[request URL], userId);


[NSURLConnection sendAsynchronousRequest:request queue:_requestOperationQueue completionHandler:^(NSURLResponse* response, NSData* data, NSError* error) {
//The first checkin has occurred bool is used to skip the splash screen.
self.firstCheckinHasOccurred = YES;

// Save the downloaded data
NSError* jsonError = nil;
NSDictionary* resultDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonError];
if(jsonError != nil) {
// do something with the error here
NSLog(@"JSON Error: %@", jsonError);
// callback(nil, jsonError);
if (OTNDataManager.shared.settingsAutoCheckin) {
dispatch_async(dispatch_get_main_queue(), ^{
[OTNDataManager.app setLocationUpdateInterval:15.0 * 60.0];
});
}

} else if (resultDictionary != nil) {
<SNIP....>
}
}];

确认...我只在运行 7.0.3 的 iPhone 5S 上看到了这一点,但没有看到两部独立的 iPhone 5,一部运行 7.0.3,另一部运行 6.1.4。它还适用于运行 7.0.2 的 iPhone 4S。此外,如果在绑定(bind)到 Xcode 时运行代码,则不会发生这种情况,只有在 Release模式下运行应用程序的编译版本时才会发生这种情况。

如果有人知道这里发生了什么,请告诉我。

最佳答案

这个问题很烦人,很难通过断点调试,我建议你在应用退出事件时尝试一些技巧,如下所示,向系统申请更多时间:

    __block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{


[[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
backgroundTaskIdentifier = backgroundTaskIdentifier;
}];

关于ios - <Application> 有超出允许时间的事件断言 - 仅限 iPhone 5S,适用于 iPhone 5、4s 和 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19696224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com