2017-02-01 3 views
1

私は、リモート通知の内容を変更することができるIOSの通知サービス拡張を使用してリモート通知にメディアを添付することはできません通知サービス拡張のしかし、イメージやムービーをダウンロードして、添付ファイルとしてコンテンツに追加することはできませんでした。は<br> "FUNC didReceive( - >ボイド@escaping(UNNotificationContent):UNNotificationRequest、 withContentHandlerのContentHandler _要求)" を使用して10

このメソッドを使用してリモート通知にメディアを追加するにはどうすればよいですか。

答えて

0

私はここを参照してください、プロセスを簡素化するために拡張を書いた: UNNotificationAttachment with UIImage or Remote URL

次にあなたがこの

let identifier = ProcessInfo.processInfo.globallyUniqueString 
let content = UNMutableNotificationContent() 
content.title = "Hello" 
content.body = "World" 
if let attachment = UNNotificationAttachment.create(identifier: identifier, image: myImage, options: nil) { 
    // where myImage is any UIImage that follows the 
    content.attachments = [attachment] 
} 
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 120.0, repeats: false) 
let request = UNNotificationRequest.init(identifier: identifier, content: content, trigger: trigger) 
UNUserNotificationCenter.current().add(request) { (error) in 
    // handle error 
} 
のように画像を含めることができます
関連する問題