0

I am trying to display an image from the app asset catalogue as an attachment in the push notification.

I have used these articles and questions as source of inspiration: UNNotificationAttachment with UIImage or Remote URL https://www.avanderlee.com/ios-10/rich-notifications-ios-10/

The approach works well except for one image. For this image the notification service extension crashes with:

Thread 2: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=12 MB, unused=0x0)

The crash happens after calling the method pngData() on the UIImage.

The crash does not seem to be directly connected to the size of the image file on the disc, as several other images that work with this approach are somewhat bigger (we're talking about ranges from 10KB to 25KB approximately).

Any idea how I could circumvent this issue? I tried so far using jpegData(compressionQuality:) instead, but again the same image causes problems, whereas the others work.

Banana
  • 4,010
  • 9
  • 33
  • 49

1 Answers1

0

I finally solved this by not using the asset catalogue at all, but rather saving the attachments directly in the bundle, finding the URL to the attachments in the bundle and then using this URL to display the attachment in the push.

Banana
  • 4,010
  • 9
  • 33
  • 49