2016-08-22 57 views
5

iOS10通知允許我們將圖像添加爲媒體附件給他們。 不幸的是,我還沒有找到任何好方法來控制通知內附件的外觀。ios 10中的媒體附件作物圖像通知

例如,我添加作爲附件這一形象: enter image description here

而且它顯示爲:

enter image description here

我傳遞方的圖像,並希望避免圖像 - 作物(正如你可以看到貓的一隻耳朵已被切割)。

我通過這個片段發送notifcation(作爲本地一個):

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){ 
     } 
    } 

所以問題是

  • 我能避免圖像作物? (如果沒有 - 如何在刪除所有圖像?)
  • 獎金的問題:是否有一種方式來顯示2個媒體附件在一個通知(而它的崩潰)

謝謝!

+1

也許用'UNNotificationAttachmentOptionsThumbnailClippingRectKey'把在選項參數到'UNNotificationAttachment'創建方法?有關更多信息,請參閱文檔。 – Larme

+0

@Larme感謝您的評論! Doc看起來很有希望,但在現實生活中從未成功實現它(Xcode-beta5,iOS 10 beta 5)。你試過了嗎? –

+3

我因爲貓而投了票。 (當然還有一個很好的問題)。 – tymac

回答