Skip to content

Commit

Permalink
minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kas-kad committed May 29, 2017
1 parent 153387e commit 7524d01
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Pod/Classes/RichNotifications/RichNotificationsExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@ final public class MobileMessagingNotificationServiceExtension: NSObject {
}

public class func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
guard let mtMessage = MTMessage(payload: request.content.userInfo, createdDate: Date()) else
guard let sharedInstance = sharedInstance, let mtMessage = MTMessage(payload: request.content.userInfo, createdDate: Date()) else
{
contentHandler(request.content)
return
}
sharedInstance?.reportDelivery(mtMessage)
sharedInstance?.currentTask = mtMessage.downloadImageAttachment { (url, error) in
sharedInstance.reportDelivery(mtMessage)
sharedInstance.currentTask = mtMessage.downloadImageAttachment { (url, error) in
guard let url = url,
let mContent = (request.content.mutableCopy() as? UNMutableNotificationContent),
let attachment = try? UNNotificationAttachment(identifier: url.lastPathComponent, url: url, options: nil) else {
contentHandler(request.content)
return
let attachment = try? UNNotificationAttachment(identifier: String(url.absoluteString.hash), url: url, options: nil) else
{
contentHandler(request.content)
return
}

mContent.attachments = [attachment]
Expand Down

0 comments on commit 7524d01

Please sign in to comment.