Quickblox:如何识别QBActionStatusDelegate中哪个推送通知发送失败

时间:2014-01-17 12:17:50

标签: ios sdk quickblox

我的应用程序使用Quickblox推送通知API和他们的iOS SDK发送推送通知。我能够使用有效负载信息成功地在设备中发送和接收推送通知。

但是,现在的问题是,如果发送失败,如何识别 QBActionStatusDelegate 中哪个推送通知发送失败?请在此假设已发出多个推送通知发送并在后台同时处理。

背景资料:

我正在发送这样的消息(假设在此之前设置了正确的有效负载):

QBMPushMessage *message = [[QBMPushMessage alloc] initWithPayload:payload];
[QBMessages TSendPush:message toUsers:[NSString stringWithFormat:@"%d", USERID] delegate:self];

然后我收到这样的行动状态结果:

#pragma mark QBActionStatusDelegate    
- (void)completedWithResult:(Result *)result
{
    if ([result isKindOfClass:QBMSendPushTaskResult.class]) {
        // Send Push Notifications result
        if (result.success) {
            // success
        }
        else {
            // failed

            // TODO: try to resend the push notification
            // how?
        }
}

发送失败时的使用情况,例如当设备超出网络覆盖范围且连接不良时。请参阅此案例中的日志。

<Warning>: AA MyMessagingService/QBActionStatusDelegate/completedWithResult:
QBMSendPushTaskResult failed; errors=("Connection closed due to timeout. Please 
check your internet connection."), status=0

我正在使用适用于iOS的Quickblox SDK库(最新git提交:2013年12月30日星期一12:42:14 +0200)

2 个答案:

答案 0 :(得分:1)

如果我理解你可以创建一些方法,如:

 -(void)sendPushToUser:(NSInteger)userID parameters:(NSDictionary *)params {
     //
     // get some info like payload and user id
     QBMPushMessage *message = [[QBMPushMessage alloc] initWithPayload:payload];
     [QBMessages TSendPush:message toUsers:[NSString stringWithFormat:@"%d", userId] delegate:self];
  }

并在

中调用它
   // TODO: try to resend the push notification
   // how?

对于错误的连接:良好的做法是使用可达性(例如https://github.com/tonymillion/Reachability)。在这种情况下,在连接丢失后,您可以锁定发送任何请求,并在连接再次出现时解锁。

对于检查请求失败或不使用result.success以及result.errors字段。

答案 1 :(得分:1)

尝试使用上下文 - 它有助于识别查询

http://quickblox.com/developers/IOS#Performing_actions_with_context

相关问题