听完背景插座几分钟后的SIGSTOP

时间:2012-03-26 13:57:38

标签: ios

我有一个在后台运行的后台cocoaasyncsocket套接字。

//DELEGATE
- (void) socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
    self.i += 1;
    NSLog(@"didReadData %d %@", self.i, [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
    [self.asyncSocket readDataWithTimeout:-1 tag:0];

}

- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port 
{
    NSLog(@"socket:%p didConnectToHost:%@ port:%hu", sock, host, port);

    [self.asyncSocket performBlock:^{
        [self.asyncSocket enableBackgroundingOnSocket];
    }];

    [self.asyncSocket readDataWithTimeout:-1 tag:0];

}

//。plist中

<key>UIBackgroundModes</key>
<array>
    <string>voip</string>
</array>

在我获得SIGSTOP和应用程序“崩溃”之后的前3分钟它运行正常。你知道为什么吗?

1 个答案:

答案 0 :(得分:6)

您可以在管理器中检查原因(从XCode点击Window - &gt; Organizer - &gt;您的iOS设备 - &gt;设备日志 - &gt;您的应用程序)。

就我而言,它是这样的:

Application Specific Information:
BKUnsuspendLimit MyApp[5168] exceeded 15 wakes in 300 sec

事实证明,你的应用程序在300秒内被唤醒的次数有限制。