Repository navigation
Conversation
The notification service extension saves the confirmation to the App Group
and sends one POST with the body {} and dateTimeOffset, waiting up to 5 s.
What did not get through, the app hands to guaranteed delivery on start
and on return to the foreground. The code shared by both modules lives
in Mindbox/Shared.
MOBILE-541 pauses on 429 instead of dropping the event, so the queued confirmation now stays after 429. The test builds DeliveryOperation with the pause and retry delay managers MOBILE-541 added.
The system may stop the extension right after pushDelivered returns, so the file for the app is saved synchronously and only the request runs in a Task.
|
Before the first unlock after a restart the file is closed, and the app removed it as broken. Only a file that is read but cannot be decoded is removed now.
A file younger than the wait of the extension plus a second may still be on its way, so the app takes it a bit later instead of sending the confirmation a second time.
iOS 17 and later percent-encoded characters a URL may not contain, which can break its signature. Such a URL now asks for no confirmation on every iOS, as on iOS 15 and 16 and on Android.
pushDelivered writes the log line again, as before. The rich push guide tells apps with their own extension to call pushDelivered and allows didReceive after it, which sent two confirmations for one push. didReceive prints the same log line itself.
An app that keeps no reference to MindboxNotificationService released it while didReceive waited for the confirmation, so a push without an image showed only when the extension ran out of time.
There was a problem hiding this comment.
Проверил сборками на голове PR (Xcode 27.2): SPM, как у Flutter-плагина; CocoaPods static и use_frameworks! (app + NSE); архивы XCFramework. CocoaPods и обёртки не ломаются.
Главное
- Таймаут ГД —
MBEventRepository.swift:28. - 5xx от приёмника растит общую задержку ГД —
MBEventRepository.swift:192. - Privacy-манифест
MindboxNotificationsпустой, хотя расширение теперь отправляет данные. Нужная запись — в комментарии ниже. После правки проверить в TestFlight.
Комментарии. Убрать все, кроме doc публичного API для клиента. Общий код и внутренние типы клиенту не видны, причины изменений описываются в коммитах. Шапки с копирайтом остаются.
До мержа
- Живой прогон через sandbox APNs на симулятор iOS 16+ (
simctl pushNSE не запускает): пуш без картинки, пуш с картинкой, ответ 500 → досылка из приложения. - Зелёный SPM-job. В
feature/MOBILE-541его нет, поэтому на этом PR он не запускался. - Обновить описание PR:
pushDelivered(_:)больше не пишет файл, а «Foundation only» неверно (есть CryptoKit).
DoD: п.5 разделить на «из расширения ≤3 с» и «из ГД ≤5 с»; п.7 про http переформулировать — iOS и Android http-URL не вызывают.
| trackingIdsResolver: TrackingIdsResolver, | ||
| trackingHostResolver: TrackingHostResolver) { | ||
| trackingHostResolver: TrackingHostResolver, | ||
| pushDeliveryConfirmationSender: PushDeliveryConfirmationSender = PushDeliveryConfirmationSender()) { |
There was a problem hiding this comment.
Здесь нет таймаута, работают системные 60 с. Очередь ГД последовательная: если приёмник молчит, install, клики и операции ждут до 60 с на каждое подтверждение. По DoD и как на Android (MOBILE-650) — 5 с:
PushDeliveryConfirmationSender(timeout: PushDeliveryConfirmation.guaranteedDeliveryRequestTimeout)| case let .failed(statusCode?): | ||
| completion(.failure(.serverError(.init( | ||
| status: .internalServerError, | ||
| errorMessage: "Push delivery confirmation failed", | ||
| httpStatusCode: statusCode | ||
| )))) | ||
| case .failed(nil): | ||
| completion(.failure(.connectionError)) |
There was a problem hiding this comment.
5xx и редирект сейчас становятся .serverFailure и растят общую задержку ГД до 3600 с. Повторы install, кликов и операций будут ждать до часа из-за сбоя приёмника. С .connectionError подтверждение остаётся в очереди, но паузу и общую задержку не трогает. Тест serverErrorIsServerError поправить вместе с этим.
| case let .failed(statusCode?): | |
| completion(.failure(.serverError(.init( | |
| status: .internalServerError, | |
| errorMessage: "Push delivery confirmation failed", | |
| httpStatusCode: statusCode | |
| )))) | |
| case .failed(nil): | |
| completion(.failure(.connectionError)) | |
| case .failed: | |
| completion(.failure(.connectionError)) |
|
|
||
| /// How long the notification service extension waits for the answer before the push is shown. | ||
| /// Until then the app leaves the file of the confirmation alone: the extension may still be sending it. | ||
| public static let extensionWaitLimit: TimeInterval = 5 |
There was a problem hiding this comment.
5 с в DoD пришли из Android-задачи. Там это про воркер ГД, и показ пуша запроса не ждёт. Здесь это задержка показа пуша без картинки. Если запрос не прошёл, досылка всё равно будет только при следующем запуске приложения, так что лишние 2 с почти ничего не дают. Предлагаю:
package static let extensionRequestTimeout: TimeInterval = 3
package static let guaranteedDeliveryRequestTimeout: TimeInterval = 5inFlightWindow считать от первой константы. Нынешние extensionWaitLimit и waitLimit убрать: сейчас у одного значения три имени.
| // Compiled straight into each module by CocoaPods and the Xcode project; SwiftPM needs it as a target. | ||
| .target( | ||
| name: "MindboxShared", | ||
| path: "Mindbox/Shared" |
There was a problem hiding this comment.
Mindbox/Shared лучше вынести в корень, в MindboxShared/ рядом с SDKVersionProvider/. Тогда уйдёт exclude, а путь будет одинаковым в Package.swift, podspec и правиле линтера.
| } | ||
|
|
||
| /// `group.cloud.Mindbox.<bundle id of the host app>`, the App Group the SDK documents for the app and its extensions. | ||
| static func hostAppGroupIdentifier(bundle: Bundle) -> String? { |
There was a problem hiding this comment.
Поиск host-бандла из .appex дублирует MBUtilitiesFetcher. Если выносить его в общий код, то вместе со строкой формата, иначе MindboxAppGroup ничего не даёт.
|
К пункту 3 — запись для <key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeProductInteraction</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
<string>NSPrivacyCollectedDataTypePurposeAnalytics</string>
</array>
</dict>
</array>
После правки загрузить PushOk в TestFlight и проверить privacy report для |
- The shared imports rule also catches `import class/struct Module.Symbol`, and its message no longer claims Foundation only. - EventRoute asserts when asked for the path of a push delivery confirmation. - PayloadKey.deliveredUrl matches the payload key, PushDeliveryConfirmation.id becomes fileName. - The headers of Mindbox/Shared keep only the copyright.
Замечания остаются комментариями, без блокировки мержа.
When a push carries
callbacks.deliveredUrl, the SDK now tells Mindbox that the push reached the phone.Notification service extension
{}and the query parameterdateTimeOffset(milliseconds since the push arrived), waiting no longer than 5 s.didReceiveshows the push once both the image and the answer are in, or at the timeout.pushDelivered(_:)keeps its signature. It writes the file before it returns and does not wait for the answer.confirmDelivery(_:) asynconMindboxNotificationService, for clients with their own extension who want to wait for the answer.App
MobilePush.PushDeliveryConfirmation.dateTimeOffset. It needs neither the configuration nor the device UUID.The code both modules use lives in
Mindbox/Shared/PushDeliveryConfirmation/: Foundation only, SPM targetMindboxShared, and a path inMindboxNotifications.podspec. The SwiftLint ruleshared_code_importskeeps other imports out.The PR targets
feature/MOBILE-541, because it relies on the 429 pause from that branch.Checked
DateFormatMigrationTests, which fail ondeveloptoo.--strictover the whole repo: 0 violations.dateTimeOffset;Not checked on the simulator: the extension path. Simulated pushes (
simctl push) do not launch a notification service extension, so this path needs a real APNs push on a device. Unit tests cover it.https://tracker.yandex.ru/MOBILE-652