Skip to content

Always deliver notification content from the service extension - #2533

Open
meet4731 wants to merge 1 commit into
Dimillian:mainfrom
meet4731:fix/2447-notification-time-will-expire
Open

meet4731 wants to merge 1 commit into
Dimillian:mainfrom
meet4731:fix/2447-notification-time-will-expire

Conversation

@meet4731

@meet4731 meet4731 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Related to #2447 and #2438

The notification service extension could stop without ever calling its content handler. In buildContent(), the paths after the icon download (the image does not decode, the follow-up API request fails, or the notification type is unsupported) fell through to return nil, and didReceive only called the handler when it got content back. iOS then waited for the time limit and showed the unencrypted fallback text, "A new notification has been received." This matches the 30 second delay described in #2447. Before the Swift 6 changes in 6297a42, every path called the handler.

The extension also never implemented serviceExtensionTimeWillExpire, so a slow network request produced the same result.

This change keeps the handler and the content being built behind a lock, adds serviceExtensionTimeWillExpire so the decrypted title and body are delivered when time runs out, makes sure the handler is called at most once, and adds the missing return after the attachment path.

Testing: the IceCubesNotifications scheme builds. I sent test pushes to an iPhone SE simulator with simctl push, but the simulator does not run notification service extensions, so the expiry path could not be exercised there. It needs a device with a real push to confirm.

The extension could stop without calling its content handler: after
the icon download, several paths in buildContent() fell through to
return nil, and didReceive only called the handler when it got content
back. It also never implemented serviceExtensionTimeWillExpire. In both
cases iOS waited for the time limit and showed the unencrypted fallback
text instead of the decrypted title and body.

Keep the handler and the content being built behind a lock, deliver the
best attempt when time runs out, call the handler at most once, and add
the missing return after the attachment path.

Related to Dimillian#2447
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