Delivery and Retries
The SDK sends a request to Positive User for every ping, event and notification report. What happens when a request fails depends on the platform. This page explains what is retried, what is dropped and what your code sees.
What it is
iOS puts pings, events, screen events, product events and notification reports in a queue on the device. The queue is saved, so requests created offline or right before the app closes are sent later. A request waiting for a retry does not hold back newer requests. The logout event, the removal of the token at logout and the anonymous ping after logout are sent directly, outside the queue.
Android works the same way: pings, events, screen events, product events, notification reports and the requests of logout go through one saved queue. A request waiting for a retry does not hold back newer requests.
Flutter sends each request straight away and saves only requests that failed because of a network error.
How it works
Results
The table shows how the iOS SDK and the Android SDK handle each answer. Flutter differs in places, see Platform differences.
| Server answer | What the SDK does |
|---|---|
| Success (2xx) | Removes the request from the queue. |
| Rejected (4xx other than 429), for example a wrong key or an invalid event | Removes the request. It would fail again. |
| Server error (5xx) or no network | Keeps the request and retries it later. |
| Rate limit (429) | Keeps the request and retries it no sooner than the server asks for in Retry-After. |
A request rejected by the firewall (HTTP 403, for example for content that looks like an attack) is also a rejection. On iOS, Android and Flutter it is not retried and the event is lost.
Checked before sending
On iOS and Android, some calls end with an error before any request: an event before the first successful ping, an invalid event or screen name, an empty product ID, and attribute values JSON cannot hold. Nothing is queued in these cases. See Errors for iOS and Android.
Offline
On iOS and Android, while the device has no network, nothing is sent and nothing is counted as a failed attempt. The queue starts again when the network returns.
Partly accepted events
The backend can accept an event and drop some of its attributes, for example an attribute with a value of the wrong type. The event is recorded and the request counts as a success.
Platform differences
| iOS | Android | Flutter | |
|---|---|---|---|
| Saved on the device | Every queued request | Every queued request | Requests that failed on network errors |
| Retries of server errors | Up to 4 attempts in total, also for 429, after about 30 s, 90 s and 210 s. Other requests keep going out in the meantime. The attempt count starts again after the app restarts. | Up to 4 attempts in total, also for 429, after about 30 s, 90 s and 210 s. Other requests keep going out in the meantime. The attempt count starts again after the app restarts. | Not retried |
| Rejected requests (4xx) | Dropped, except 429 | Dropped, except 429 | Not retried |
| Result in your code | Completion handler on the main thread: true on success, false with a UserSDKError on rejection or after the last retry. UserSDK.errorHandler receives every error, also from calls without a completion | Optional callback on the main thread, null on success, a UserComError on rejection or after the last retry. UserCom.errorHandler receives every error | No result |
A request waiting in the queue is not an error: its result comes when it is sent or finally dropped. A request that is still waiting when the app closes is sent after the next launch. On iOS and Android its completion handler or callback is not called in that case.
On iOS and Android, logout drops the pings still waiting in the queue, and their completion or callback reports loggedOut. Events still waiting are sent for the contact who logged out.