Quickblox: how to recognize which push notification sending failed in QBActionStatusDelegate

StackOverflow https://stackoverflow.com/questions/21185841

  •  29-09-2022
  •  | 
  •  

Question

My application is sending push notifications using Quickblox push notification API with their iOS SDK. I am able to send and receive push notifications in the device successfully with payload information.

But, now the question is, in case of sending fails, how to recognize which push notification sending failed in QBActionStatusDelegate? Please assume here that multiple push notifications has been sent and are being processed in the background simultaneously.

Background information:

I am sending message like this (assume that correct payload has been set prior to this):

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

Then I receive the action status result like this:

#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?
        }
}

Use case when the sending has failed is for instance when the device is out of network coverage and does have bad connection. See logs from this case.

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

I am using Quickblox SDK library for iOS (latest git commit: Mon Dec 30 12:42:14 2013 +0200)

Was it helpful?

Solution

Try to use context - it helps to recognise queries

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

OTHER TIPS

If I right understand you can create some method like :

 -(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];
  }

and invoke it in

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

For bad connection : good practice is using Reachability (example https://github.com/tonymillion/Reachability). In this case after lost connection you able to lock sending any requests and unlock when connection appear again.

For check request failed or not use result.success and also result.errors fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top