iphone - iOS 应用前台同时出现多个推送通知时如何处理

标签 iphone ios httpwebrequest apple-push-notifications

我已经在 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:发送请求和获取响应的方法………​​…

请建议我如何处理。

  1. 当多个推送通知到来时委托(delegate)方法调用了多少次?
  2. 发送 http 请求和得到响应之间需要多长时间(最长时间)?

最佳答案

  1. 它会为每个到达您设备的推送通知调用一次,但如果您一次向同一设备发送太多通知,APNS 服务器可能只会将其中的一些通知发送到设备.

  2. 这不是您应该依赖的东西。您应该对您的服务器进行异步调用,以免挂起/崩溃您的应用程序。

关于iphone - iOS 应用前台同时出现多个推送通知时如何处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16716455/

相关文章:

iphone - 从 .NET WCF4 Web 服务返回 .plist

iphone - AFNetworking UIImageView setImageWithURLRequest 返回响应代码 0

objective-c - 具有回调方法的 IOS Grand Central Dispatch

c# - Windows Phone 8 的 WebResponse 是否跳过 set-cookie header

windows-phone-7 - MPNS 发送推送禁止响应 403

iphone - 如何在iPhone中制作UIButton垂直 slider 菜单

iphone - 音频流API:Wifi与什么?

iphone - ZoomingPDFViewer无法在启用分页的UIScrollViewer中缩放

ios - Xcode 错误有关 plist : ACL=<not found> 的额外信息

Silverlight 流式上传