UNNotificationAttachment results in error code 100 "Invalid attachment file URL" since iOS 16.4

Since iOS 16.4.1 (potentially also 16.4, the last known working version was 16.3.1) some of our apps are unable to add notifications to UNUserNotificationCenter using add(_:withCompletionHandler:) iff these notifications have an attachment. The internal testing flavour of the same app, exactly the same code just with a different app icon, continues to work without any issues.

The error message we receive in the completionHandler of ‌add(_:withCompletionHandler:) is Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}. StackOverflow didn't yield any useful results.

Digging deeper we looked at the console output of one of our test devices and noticed that SpringBoard logs Cannot stage attachment. Must provide either a connection or proxy, and not both immediately before the error is returned in our app.

Is this actually an issue outside of our app?

Is there something we can do to resolve this issue?

Log from an iPhone 14 using iOS 16.5 Developer Beta 2 after receiving a push notification in our application.

error	14:14:13.211481+0200	SpringBoard	XPC current connection is unexpectedly nil
fault	14:14:13.211920+0200	SpringBoard	Cannot stage attachment. Must provide either a connection or proxy, and not both. Attachment: 'file:///private/var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg'
fault	14:14:13.211970+0200	SpringBoard	Cannot stage attachment. Must provide either a connection or proxy, and not both. Attachment: 'file:///private/var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg'
error	14:14:13.212024+0200	SpringBoard	Attachment file is not related to bundle: fileURL=file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, bundleIdentifier=<private>, stagingError=(null)
error	14:14:13.212076+0200	SpringBoard	Attachment file is not related to bundle: fileURL=file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, bundleIdentifier=<private>, stagingError=(null)
error	14:14:13.212131+0200	SpringBoard	Unable to resolve URL: attachment=<UNNotificationAttachment: 0x281546980; identifier: Image, URL: file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x280647200; displayLocation: default; thumbnailGeneratorUserInfo: {
}>>, error=Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
error	14:14:13.212182+0200	SpringBoard	Unable to resolve URL: attachment=<UNNotificationAttachment: 0x281546980; identifier: Image, URL: file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x280647200; displayLocation: default; thumbnailGeneratorUserInfo: {
}>>, error=Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
error	14:14:13.212234+0200	SpringBoard	Unable to stage attachment: attachment=<UNNotificationAttachment: 0x281546980; identifier: Image, URL: file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x280647200; displayLocation: default; thumbnailGeneratorUserInfo: {
}>>, error=Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
error	14:14:13.212286+0200	SpringBoard	Unable to stage attachment: attachment=<UNNotificationAttachment: 0x281546980; identifier: Image, URL: file:///var/mobile/Containers/Data/PluginKitPlugin/********-****-****-****-************/Library/Caches/Images/Image.jpg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x280647200; displayLocation: default; thumbnailGeneratorUserInfo: {
}>>, error=Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
error	14:14:13.212444+0200	SpringBoard	Hit error staging attachment, will roll back: error=Error Domain=UNErrorDomain Code=100 "Invalid attachment file URL" UserInfo={NSLocalizedDescription=Invalid attachment file URL}
default	14:14:13.212548+0200	SpringBoard	[com.*ourAPP*] Notification serviced by the communication context service: 0. Has context: 0. Type: (null)

Log from an iPhone 14 using iOS 16.5 Developer Beta 2 after receiving a push notification in our internal test application.


error	14:24:13.307140+0200	SpringBoard	File at '<private>' already exists in the repository
default	14:24:13.307198+0200	SpringBoard	Moved attachment file into repository: attachment=<UNNotificationAttachment: 0x28053b940; identifier: Image, URL: file:///var/mobile/Containers/Data/PluginKitPlugin/D12633C1-E060-4CCC-95FD-16C5AC9E3005/Library/Caches/Images/Image.jpg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x28105a220; displayLocation: default; thumbnailGeneratorUserInfo: {
}>>, repositoryURL=file:///var/mobile/Library/UserNotifications/********-****-****-****-************/Attachments/Image.jpeg
default	14:24:13.307667+0200	SpringBoard	Successfully resolved request: resolvedRequest=<UNNotificationRequest: 0x281e05860; identifier: ******, content: <UNNotificationContent: 0x9be9db0a0; title: <redacted>, subtitle: (null), body: <redacted>, summaryArgument: , summaryArgumentCount: 0, categoryIdentifier: SINGLE, launchImageName: , threadIdentifier: ********, attachments: (
    "<UNNotificationAttachment: 0x28053f480; identifier: Image, URL: file:///var/mobile/Library/UserNotifications/********-****-****-****-************/Attachments/Image.jpeg, type: public.jpeg, options: <UNNotificationAttachmentOptions: 0x28105a220; displayLocation: default; thumbnailGeneratorUserInfo: {\n}>>"
), badge: 3, sound: <UNNotificationSound: 0x283b4aca0>, realert: 0, interruptionLevel: 1, relevanceScore: 0.00, filterCriteria: (null), trigger: (null)>, resolutionSuccess=YES, continueOnFailure=NO
default	14:24:13.307780+0200	SpringBoard	[com.*ourApp*] Notification serviced by the communication context service: 0. Has context: 0. Type: UNNotificationContentTypeDefault
default	14:24:13.307832+0200	SpringBoard	Getting effectiveSectionInfo for section identifier: com.*ourApp*
default	14:24:13.307883+0200	SpringBoard	[com.*ourApp*] Getting effective section info
default	14:24:13.308689+0200	SpringBoard	[com.*ourApp*] Got effective section info [ hasResult: 1 ]
Answered by ForumsContributor in 754798022

This seems to have been fixed with the iOS 17.0 Beta 1.

I faced with same problem, did anyone have solution for it?

Accepted Answer

This seems to have been fixed with the iOS 17.0 Beta 1.

No, but it seems to have been fixed with the first beta of iOS 17.0.

UNNotificationAttachment results in error code 100 "Invalid attachment file URL" since iOS 16.4
 
 
Q