How to display an icon in a notification without it being clipped

If I add an image to a notification then when its displayed as an icon in the notification compact state what is shown is just the the center of the image and not all of the image.


So I tried passing clipping options as below:


                    let clipping = CGRect(x: 0, y: 0, width: 1.0, height: 1.0)
                    let options: Dictionary<String, AnyObject> = [UNNotificationAttachmentOptionsThumbnailClippingRectKey: clipping.dictionaryRepresentation]
                    let icon = try UNNotificationAttachment(identifier: "icon", url: url, options: options)

But it made no difference.

Replies

It seems to me that a fixed clipping rect of (0.25, 0.25, 0.5, 0.5) is being used, irrespective of whether you supply your own clipping rect or not. (I've only tested in beta 3). This is surely a bug. Did you raise a radar?

I've seen the same behavior and agree with hacknicity that this appears to be a bug in the iOS Beta. I would also recommend filing a Radar against this.

I saw this too and now with iOS10 GM dove in a little deeper.


UNNotificationAttachmentOptionsThumbnailClippingRectKey does have an effect, but only to crop the photo MORE and you can't use a negative outset to uncrop.To get uncropped photos I'm rendering them 50% bigger... Would like to hear from Apple on this.