Image of attachment cultures in ios 10 app

iOS10 notifications allow us to add images as media attachments . Unfortunately, I did not find a good way to control the appearance of the application inside the notification.

For example, I add this image as an attachment: enter image description here

And he shows how:

enter image description here

I am transferring square images and want to avoid cropping the images (since you can see that one cat's ear has been cut).

I am sending notifcation (as local) through this snippet:

let content = UNMutableNotificationContent() content.title = "Test notification" content.body = "Test notification" content.categoryIdentifier = "myNotificationCategory" let attachement = try! UNNotificationAttachment(identifier: "image", url: Bundle.main.url(forResource: "cat", withExtension: "png")!, options: nil) content.attachments = [ attachement ] let request = UNNotificationRequest(identifier:requestIdentifier, content: content, trigger: nil) UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().add(request){(error) in if (error != nil){ } } 

So the questions are :

  • Can cropping be avoided? (If not - how to delete the image at all?)
  • Bonus question: is there a way to show 2 media attachments in one notification (while it crashed).

Thanks!

+5
source share

All Articles