Skip to content

MOBILE-658: Retry the delivery confirmation three times in the notification extension - #859

Open
Vailence wants to merge 6 commits into
mission/transactional-pushfrom
feature/MOBILE-658-extension-cascade
Open

Vailence wants to merge 6 commits into
mission/transactional-pushfrom
feature/MOBILE-658-extension-cascade

Conversation

@Vailence

Copy link
Copy Markdown
Collaborator

The cascade sends an SMS when the delivery confirmation of a push does not arrive within 45 seconds. After MOBILE-652 the notification service extension makes one request, and a single failed answer already costs the SMS. The extension now tries three times before it shows the push, and leaves a record for the application when all three fail.

What changes in didReceive(_:withContentHandler:):

  • up to three attempts in a row, with no pause between them; each waits for the answer for at most 3 seconds. 5xx, 429 and no answer do not stop the attempts;
  • the push is shown after the attempts are over. The worst case is about 9 seconds, when the server does not answer at all;
  • 2xx removes the record and writes the marker last-success with the time in milliseconds. The application will use it to reset its retry pause;
  • 3xx and 4xx except 429 remove the record with no more attempts. Before this PR a 3xx kept the file; the redirect is still not followed;
  • while the attempts run the record is <sha256 of the URL>.pending. After three failures it becomes <sha256>.json with lastStatusCode (absent when there was no answer) and lastAttemptAt;
  • the record files and the marker are written without file protection, like the SDK databases.

The record format moves to a new folder, MindboxShared: one struct with five fields and the names of the files. It is compiled into both Mindbox and MindboxNotifications — a target in Package.swift, source_files in the two podspecs, both targets in the Xcode project — the same way SDKVersionProvider is. The type is @_spi(Internal), so the public API does not change. The main module does not use it yet.

Not in this PR:

  • the application does not read the records. That is the rest of the stack: the rules of the delivery queues, then the confirmation queue in the application;
  • the extension writes no log lines. They come in a separate PR, once the texts are agreed;
  • clients with their own notification service get no confirmation: pushDelivered(_:) still only writes a log. That is MOBILE-657.

One difference from Android (MOBILE-656): there the attempts go at seconds 0, 3 and 6. Here they go without a pause, because on iOS the push is shown only after them, and a pause would delay every push whose confirmation fails fast.

Checked on an iPhone 16 Pro (iOS 27.0.1) with sandbox pushes from the Push Notifications console, the delivered URL routed through Proxyman to a local mock:

  • 200: one request, the push is shown at once, only last-success is left;
  • 500, 500, 200: three requests about 7 ms apart, shown at once, with and without an image;
  • 500 or 429 on every attempt: three requests within 15–21 ms, a .json record with the last status code;
  • 404: one request, no record. 302: one request, the redirect is not followed, no record;
  • no answer: three requests dropped after about 3 seconds each, the push is shown after about 9 seconds, a .json record without a status code;
  • a push without callbacks or with an http:// URL: no request, no record;
  • two pushes with the same URL: six requests, one record.

Every request was a POST with the body {}, the four SDK headers and a dateTimeOffset that grows from attempt to attempt. No .pending file was left after a push was shown.

The device run was made before the record format moved to MindboxShared. After that: the Swift package builds from a copy without the Xcode project, pod lib lint passes for both podspecs with static and dynamic linkage (the main pod against the local MindboxLogger.podspec), and the test application builds for the simulator with its extensions.

Not checked: a write on a locked device of an application with Data Protection set to Complete. The protection of the files was confirmed only by their attributes.

Unit tests: MindboxNotificationsTests pass (96). In the full local run 2739 tests pass and 3 fail, all in DateFormatMigrationTests of the main module, which this PR does not change apart from compiling the shared file.

https://tracker.yandex.ru/MOBILE-658

Vailence added 6 commits November 24, 2026 17:20
The application picks the records up on SDK start, on becoming active
and on background wakes of the delivery queue.
…module

The record and the names of its files are compiled into both Mindbox and
MindboxNotifications from the MindboxShared folder, so the extension and
the application cannot drift apart.
@github-actions

Copy link
Copy Markdown
Contributor
TestsPassed ✅SkippedFailedTime ⏱
Unit tests report3252 ran3252 ✅3m 58s 332ms

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant