Local notification image attachment not displayed for App Store builds

I have an app that schedules a handful of local notifications with trigger dates 1 to 4 weeks in the future. Each notification has a single image attachment with a JPEG sourced from the app's main bundle.

In development builds via Xcode, or builds via TestFlight, the notifications do appear in the notification center and they do display an image. However, in App Store builds, the notifications appear, but they do not display an image.

I have ruled out the following:

  • Images may not be included in the bundle
  • Images may be too large or unsupported (they are ~50KB 480x480 JPEGs, and the docs say validation happens at scheduling time)
  • The iOS device may have no free disk space

I'm leaning towards either:

  • Differences in file protection in App Store builds (though the docs say the app process must have access to the image and images in the bundle are copied)
  • The notifications are scheduled too far in the future and if the image is copied from the bundle to temporary storage, it gets wiped before display

Does anyone have any insight?

Sample code to schedule the notification below:

    let dateComponents = // Some date in the future
    let content = UNMutableNotificationContent()
    content.title = // Some title string
    content.body = // Some body string
    content.userInfo = // Some app-specific dict
    if let path = Bundle.main.path(forResource: "my-image-file-name", ofType: "jpg") {
      let url = URL(fileURLWithPath: path)
      do {
        let imageAttachment = try UNNotificationAttachment(identifier: "", url: url) // Note the empty string identifier - the docs say one will be provided.
        content.attachments = [imageAttachment]
      } catch {
        print("Failed to add image to local notification")
      }
    }
    let trigger = UNCalendarNotificationTrigger(dateMatching: dateComponents, repeats: false)
    let request = UNNotificationRequest(
      identifier: "my-notification-id-here", content: content, trigger: trigger)
    UNUserNotificationCenter.current().add(request) { error in
      if let error = error {
        print("Failed to add notification request: \(error)")
      }
    }

FWIW images randomly aren’t there in my local notifications either, though I believe it replicates in all environments (debug, TestFlight, App Store).No idea why, seems to be an iOS bug, I’d recommend filing a bug report.

Local notification image attachment not displayed for App Store builds
 
 
Q