我已经在 application:(UIApplication *)application didReceiveRemoteNotification: 的委托(delegate)方法中向服务器发送请求,但是当多个推送通知同时出现时,应用程序会因为没有而崩溃。请求发送到服务器。
在委托(delegate)方法中我写了下面的代码:
if (!downloadInboxQueue) {
downloadInboxQueue = [[NSOperationQueue alloc] init];
downloadInboxQueue.maxConcurrentOperationCount=1;
}
NSNumber *ischatnumber=[[NSNumber alloc] initWithInt:0];
operationObject=[[Operation_Inbox alloc] init];
NSInvocationOperation *operation22= [[NSInvocationOperation alloc] initWithTarget:operationObject selector:@selector(getEventFromServer:) object:ischatnumber];
[downloadInboxQueue addOperation:operation22];
operation22=nil;
NSInvocationOperation *operation2= [[NSInvocationOperation alloc] initWithTarget:operationObject selector:@selector(getEventFromServer:) object:ischatnumber];
[downloadInboxQueue addOperation:operation2];
operation2=nil;
//getEventFromServer:发送请求和获取响应的方法…………
请建议我如何处理。
- 当多个推送通知到来时委托(delegate)方法调用了多少次?
- 发送 http 请求和得到响应之间需要多长时间(最长时间)?
最佳答案
它会为每个到达您设备的推送通知调用一次,但如果您一次向同一设备发送太多通知,APNS 服务器可能只会将其中的一些通知发送到设备.
这不是您应该依赖的东西。您应该对您的服务器进行异步调用,以免挂起/崩溃您的应用程序。
关于iphone - iOS 应用前台同时出现多个推送通知时如何处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16716455/