title: Images in iOS push notification
body: <p>I am trying to send <code>images</code> in push notifications
  I have made the notifications registrations in app delegate and apns device token is generating properly.
  ALso I have coded in service ext as follows:</p>
  
  <pre><code>import UserNotifications
  
  class NotificationService: UNNotificationServiceExtension {
  
      var contentHandler: ((UNNotificationContent) -&gt; Void)?
      var bestAttemptContent: UNMutableNotificationContent?
  
      override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -&gt; Void) {
  self.contentHandler = contentHandler
  bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
  
  // Get the custom data from the notification payload
  if let notificationData = request.content.userInfo["data"] as? [String: String] {
      // Grab the attachment
      if let urlString = notificationData["attachment-url"], let fileUrl = URL(string: urlString) {
          // Download the attachment
          URLSession.shared.downloadTask(with: fileUrl) { (location, response, error) in
              if let location = location {
                  // Move temporary file to remove .tmp extension
                  let tmpDirectory = NSTemporaryDirectory()
                  let tmpFile = "file://".appending(tmpDirectory).appending(fileUrl.lastPathComponent)
                  let tmpUrl = URL(string: tmpFile)!
                  try! FileManager.default.moveItem(at: location, to: tmpUrl)
  
                  // Add the attachment to the notification content
                  if let attachment = try? UNNotificationAttachment(identifier: "", url: tmpUrl) {
                      self.bestAttemptContent?.attachments = [attachment]
                  }
              }
              // Serve the notification content
              self.contentHandler!(self.bestAttemptContent!)
              }.resume()
      }
  }
  }
  }
  </code></pre>
  
  <p>.
  And the payload in json is as follows</p>
  
  <pre><code>{
      "aps":
              {"sound":"default","alert":
                                          {"title":"iOS","body":"Hello Dude...."},
              "mutable-content": 1},
      "CustomData":
                      {"mType":"alert","m":"Hello Dude...."},
      "Attachement-url":"https://pusher.com/static_logos/320x320.png"
  } 
  </code></pre>
  
  <p>I am receiving the <strong>title</strong> and <strong>message</strong> but <strong>image</strong> is not coming.
  Please guide how to get image in push notifications</p>