gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 10:59:18 26 4
gpt4 key购买 nike

我已经在 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/

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