@ Override public void onFinishSending ( PayloadSender sender , PayloadData payload , boolean cancelled , String errorMessage , int responseCode , JSONObject responseData ) { ApptentiveNotificationCenter . defaultCenter ( ) . postNotification ( NOTIFICATION_PAYLOAD_DID_FINISH_SEND , NOTIFICATION_KEY_PAYLOAD , payload , NOTIFICATION_KEY_SUCCESSFUL , errorMessage == null && ! cancelled ? TRUE : FALSE , NOTIFICATION_KEY_RESPONSE_CODE , responseCode , NOTIFICATION_KEY_RESPONSE_DATA , responseData ) ; if ( cancelled ) { ApptentiveLog . v ( PAYLOADS , "Payload sending was cancelled: %s" , payload ) ; return ; // don't remove cancelled payloads from the queue } if ( errorMessage != null ) { ApptentiveLog . e ( PAYLOADS , "Payload sending failed: %s\n%s" , payload , errorMessage ) ; if ( appInBackground ) { ApptentiveLog . v ( PAYLOADS , "The app went to the background so we won't remove the payload from the queue" ) ; retrySending ( 5000 ) ; return ; } else if ( responseCode == - 1 ) { ApptentiveLog . v ( PAYLOADS , "Payload failed to send due to a connection error." ) ; retrySending ( 5000 ) ; return ; } else if ( responseCode >= 500 ) { ApptentiveLog . v ( PAYLOADS , "Payload failed to send due to a server error." ) ; retrySending ( 5000 ) ; return ; } } else { ApptentiveLog . v ( PAYLOADS , "Payload was successfully sent: %s" , payload ) ; } // Only let the payload be deleted if it was successfully sent, or got an unrecoverable client error. deletePayload ( payload . getNonce ( ) ) ; }
region PayloadSender . Listener