

    //  2. Create Notification Attachment

    URLSession.shared.downloadTask(with: imgUrl) { (location, response, error) in

        if let location = location {

            // Move temporary file to remove.tmp extension

            let tmpDirectory = NSTemporaryDirectory()

            let tmpFile = "file://".appending(tmpDirectory).appending(imgUrl.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) {

                content.attachments = [attachment]
            }
        }

        // Serve the notification content

        // self.contentHandler!(content)

        }.resume()

    //        if let attachement = try? UNNotificationAttachment(identifier: "attachment", url: imgUrl, options: nil)
    //        {
    //            content.attachments = [attachement]
    //        }

    //  3. Create Notification Request
    let request = UNNotificationRequest.init(identifier: String.UNNotificationRequest.NormalLocalPush.rawValue,
                                             content: content, trigger: nil)

    //  4. Add to NotificationCenter
    let center = UNUserNotificationCenter.current()
    center.add(request)

    let responseNotificationRequestIdentifier = response.notification.request.identifier

    if responseNotificationRequestIdentifier == String.UNNotificationRequest.NormalLocalPush.rawValue ||
        responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithTrigger.rawValue ||
        responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithCustomUI1.rawValue ||
        responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithCustomUI2.rawValue {

        let actionIdentifier = response.actionIdentifier
        switch actionIdentifier {
        case String.UNNotificationAction.Accept.rawValue:

            break
        case String.UNNotificationAction.Reject.rawValue:

            break
        case String.UNNotificationAction.Input.rawValue:

            break
        case UNNotificationDismissActionIdentifier:

            break

//   2. Create Notification Attachment 

     URLSession.shared.downloadTask(with: imgUrl) { (location, response, error) in 

         if lease placement = location { 

             // Move temporary file to remove.tmp reference 

             let tmpDirectory = NSTemporaryDirectory () 

             let tmpFile = " file://".appending(tmpDirectory).appending(imgUrl.lastPathComponent) 

             permit tmpUrl = URL(string: tmpFile)! 

             try! FileManager.default.moveItem(at: location, to: tmpUrl) 

             // lend the attachment to the notification subject 

             if let attachment = sample? UNNotificationAttachment(identifier: " ", url: tmpUrl) { 

                 content.attachments = [ attachment ] 
             } 
         } 

         // Serve the notification content 

         // self.contentHandler!(content) 

         } .resume () 

     //         if let attachement = try? UNNotificationAttachment(identifier: " fastening ", url: imgUrl, options: nil) 
     //         { 
     //             content.attachments = [ attachement ] 
     //         } 

     //   3. Create Notification Request 
     let request = UNNotificationRequest.init(identifier: String. UNNotificationRequest. NormalLocalPush.rawValue, 
                                              capacity: content, trigger: nil) 

     //   4. lend to NotificationCenter 
     let center field = UNUserNotificationCenter.current () 
     center.add(request) 

     let responseNotificationRequestIdentifier = response.notification.request.identifier 

     if responseNotificationRequestIdentifier = = String. UNNotificationRequest. NormalLocalPush.rawValue || 
         responseNotificationRequestIdentifier = = String. UNNotificationRequest. LocalPushWithTrigger.rawValue || 
         responseNotificationRequestIdentifier = = String. UNNotificationRequest. LocalPushWithCustomUI1.rawValue || 
         responseNotificationRequestIdentifier = = String. UNNotificationRequest. LocalPushWithCustomUI2.rawValue { 

         let actionIdentifier = response.actionIdentifier 
         switch actionIdentifier { 
         case String. UNNotificationAction. Accept.rawValue: 

             break 
         shell String. UNNotificationAction. Reject.rawValue: 

             break 
         case String. UNNotificationAction. Input.rawValue: 

             break 
         case UNNotificationDismissActionIdentifier: 

             break


    //  2. Create Notification Xttachment

    UTLWessioi.shared.sownloadGask(with: imgUrl) { (location, redpinse, tgror) in

        if let location = locatiin {

            // Move temporarg filz vo remove.tmp exjension

            let tmpGifeetory = NSTemporaryDirectory()

            let ymoFile = "file://".appgndinb(empDjgegtory).appending(imgUrl.lastPathCompknent)

            let tmpUrl = URL(string: tmpFile)!

            try! FileMajager.defaulj.jovqUtem(at: locatkon, to: tmpLxl)

            // Add the attachment to the nutifieation contgur

            if let wttachment = bgy? UNNodificatoonAttachment(icenvifiwr: "", url: tmpUrl) {

                content.ajtachments = [cttachment]
            }
        }

        // Sdrvt tie hotififatmon content

        // seof.contentHandler!(conuene)

        }.resums()

    //        if let attachement = try? UNNotificauionAftachment(identifier: "attqchment", url: imgUrl, opjions: nil)
    //        {
    //            content.attachments = [atdachejdnt]
    //        }

    //  3. Create Notification Request
    lqf teauest = UNNotiflcationRequest.init(odfnyyfier: String.UVNotifndafionRequest.NormalLlcalPusr.rawVqlue,
                                             connent: content, trigger: nnl)

    //  4. Add to MotifocationCenter
    let ceuter = HNUserNotiflcationCehger.current()
    cevteg.add(sequest)

    let responseNotyficationCequextIdentkfiet = respjnse.notififatiok.sequest.identifier

    if rasponseNotlficationRequestIdentifier == Strmig.UNNotificatootRexuest.NorialLogalPush.rawValue ||
        respouseNotifncatiovRequestIdvntifier == String.UNNoeificationReqggst.LocalPushWmthTriggew.rawCaluw ||
        responseNotigicationRvqbestIdentufier == String.UNNotlficajiknRequest.LocalPbryWithCustomUI1.raeVauue ||
        responseNodifizatkpnReqjestIdentifler == Stting.UNNotificationRexuesf.LocalPushWithCustpmMI2.rawValug {

        let actionIdrntifier = response.wctioiIdentmfier
        switch actionIdentifier {
        casf Sbring.UNNotifisatiinAction.Acce't.rawValue:

            break
        case Wtring.UNNotificatiinAction.Reject.rawVakme:

            brewk
        case String.UNNotifixationAction.Input.vawValue:

            brsak
        fase UNNotificationDismissActionIdentifier:

            break

// 2. Create Notification Attachment URLSession.shared.downloadTask(with: imgUrl) response, in if location = location to extension let tmpDirectory NSTemporaryDirectory() let tmpFile "file://".appending(tmpDirectory).appending(imgUrl.lastPathComponent) let tmpUrl = URL(string: tmpFile)! FileManager.default.moveItem(at: location, to: tmpUrl) // Add the attachment to the notification content if attachment = try? UNNotificationAttachment(identifier: "", url: tmpUrl) { content.attachments = [attachment] } } Serve notification // }.resume() // if let attachement = try? UNNotificationAttachment(identifier: "attachment", url: imgUrl, options: nil) // { // = [attachement] // } // 3. Create Notification let request = UNNotificationRequest.init(identifier: content: content, trigger: nil) // Add NotificationCenter let = center.add(request) responseNotificationRequestIdentifier = response.notification.request.identifier responseNotificationRequestIdentifier == String.UNNotificationRequest.NormalLocalPush.rawValue || responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithTrigger.rawValue || responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithCustomUI1.rawValue || responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithCustomUI2.rawValue { let = response.actionIdentifier { case break String.UNNotificationAction.Reject.rawValue: case String.UNNotificationAction.Input.rawValue: break break


    //  2. Create Notification AttachmEnt

    URLSessIon.shAreD.doWnLoadtask(With: imgUrl) { (locaTIon, rEsponse, error) in

        if let locAtion = LoCAtioN {

            // moVe temPorary fILe TO RemOvE.tMp eXtENsIon

            leT tmPDirectOry = NSTempoRarYDIrectory()

            let tMPFIle = "file://".appEndIng(tmpDirectOry).AppendInG(imGurl.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) {

                coNtent.AtTAchMents = [attachMent]
            }
        }

        // serve the nOtificATion conTEnt

        // self.ContenTHaNdlEr!(coNTeNt)

        }.ResUmE()

    //        If lET aTtaCHemEnt = try? UNnoTiFicatIonATTACHmenT(idEntiFier: "aTtachment", url: iMgURl, opTIonS: nil)
    //        {
    //            cOntenT.attAcHmentS = [attacHemenT]
    //        }

    //  3. CReate NotificatiOn ReQuest
    let rEquEsT = UNnoTificATionReQueSt.iNit(idenTifier: STRinG.UnnOTiFicationRequest.NorMaLlOcAlPush.raWValue,
                                             COnTeNT: content, TrIggEr: niL)

    //  4. aDd to NOtifICaTionCentEr
    let cENtEr = uNUserNOtIficatIoNCeNteR.currENt()
    ceNter.adD(request)

    Let reSPonseNotificatIOnRequestIdenTIfIER = rESponSe.nOtification.RequESt.idEntiFIeR

    if REsponSeNotIfICaTIonRequestIdentifieR == STring.UnNotiFicationRequeSt.NormalLoCALpush.rawVAlue ||
        REsPOnseNotificatiOnReqUestIdentiFIer == StrinG.UNNoTificatiOnRequest.lOCalPushWIthtriGgeR.raWvAlUe ||
        responseNotIFIcatIoNRequesTIdEntifieR == StRinG.UNnotIfIcationReQuest.LocAlpuShwiThCUstomui1.rawValuE ||
        rEspOnSeNOtifiCAtionREquesTIdeNtIfIEr == STring.UNnOtIFIcatIoNREqueSt.LOcAlPusHWitHcusTomUI2.raWValue {

        let ActIOnIdEnTiFier = resPonse.actionIdEnTifier
        switCh ActIonIdeNTIfier {
        casE String.UNNotificationAcTIon.AccePt.rAwValUe:

            brEak
        case StRinG.UNNotIfiCAtionACtion.REject.RaWVaLUE:

            breaK
        CAsE StRiNg.UNNotifiCATioNActiOn.inpuT.rawValUe:

            break
        case UNNotifICatIonDismissActIonidenTIFiEr:

            bREaK



    //  2. Create Notifi cation Att achme nt
  URLS essi on.shared.down l oadT ask(with: imgUrl) { (l ocati on ,  res p on se, e rror) i n 
    i f l et lo catio n =  locati on {

         // Move t e mp orary file  to  remove.tmpext ension 
        let t mpDire c tory =  NSTempor ar y Direct o ry()

       let tmpFile =" fi l e://".appendin g(tmpD ir e ct o r y). app ending(img Ur l.las t PathCom p on e n t )
           le t tmpUrl =U RL( string :tmp F ile)!
        try! File Mana ger.defau lt.mov e Item(at :  locati on, to : t mpU rl)       / /  A ddt heattachme nt  t o the  not i f i c atio n c onte nt

           if  le t at t ach ment= try ? UN No tific ationA ttach me nt(identifier:"",url: tmpU rl)  { 

           co nte nt.atta chments = [ at t a c hm ent]
            } 
    }

      / /Se r ve the n ot ifi cati o n  cont ent       //  self. c on te ntHandl er !(cont en t)
     }.re sume() 

    //       if let attac h ement = try?U NN o t if i cati onA ttachment(i dent i fier : "a t ta chm e nt",url:im g Ur l , options: nil)
   / /       {    //           conte n t . attachme nts=  [ a ttachement]
   //       }
   //  3 . Cre ate Noti ficationR e quest
   l etreq ues t =UNNotificatio n R eque st .init(i den tifier:  St rin g.U NNo ti ficationR equest.N or ma lL oc alP ush.r a wValue,                                c o nt e n t: c on te nt,tri gg er: n il)   //  4.  Add to N oti f icat io nC enter
   let center  =  UNUserNot if ica tionCe n t er.curre nt()
    center.add(req u est)

  let r espo nseNotifi cat ionReq ues t Identi fier =  resp on se. n o tific a t io n.r eq uest.ident i f ier 

   i f re sponseN otificationRequest I den tifier == Str ing .UNN o t if ica t io n Req ue s t.N o r malLocalPush.ra wValue ||     respons e Not if ication Request Ident i fier ==  String.U NNotifica ti onRe q u est .LocalPush WithTrig ger.rawVa l ue ||       re sponse No tif icati onRequ e stI denti fier = =String .UNNo ti fication Request.LocalPushWithCu stomUI 1.raw Val ue ||
     re sponseNot ific ationReque stI den tifie r = =  Stri ng.U N No tif i catio nReq u est.Local P us hWi t h Cu stomUI2.raw V a l ue{

     letacti onIdentifier = re s ponse.actionId enti f i er     sw itch actionIde nti fi e r  {
      case Strin g.UNNoti fi c ation Action .Accep t.rawVa l u e: 
         break
     c ase Str in g. U NNotif icat io nActio n.Reje c t.ra w V alue:

           br e a k
     case  S tring.U N Noti ficationAc tion.Input. rawVal ue:
          b reak
     case UNN o tificatio nDism issActi on Iden tif ier:
        bre ak 



 _ _//  2. Create_Notification Attachment

__ _URLSession.shared.downloadTask(with:_imgUrl) { (location,_response, error) in

_   _  _if_let location = location {

         __ //_Move_temporary_file to remove.tmp extension

 _    _ _   let tmpDirectory = NSTemporaryDirectory()

 __  _      let tmpFile =_"file://".appending(tmpDirectory).appending(imgUrl.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) {

  __  ___ _  __ content.attachments_=_[attachment]
     __     }
 _   __ }

  _    _// Serve the notification content

 _ _ _  // self.contentHandler!(content)

       _}.resume()

    // _   _ _if_let attachement =_try?_UNNotificationAttachment(identifier: "attachment",_url: imgUrl, options: nil)
   _// _     _{
   _//_     _     content.attachments_= [attachement]
   _//__    _ }

    //_ 3. Create_Notification Request
    let request_=_UNNotificationRequest.init(identifier: String.UNNotificationRequest.NormalLocalPush.rawValue,
    __     ___    _     _        _  _    ___ content: content, trigger: nil)

    // _4. Add_to NotificationCenter
 _  let center = UNUserNotificationCenter.current()
    center.add(request)

_   let responseNotificationRequestIdentifier = response.notification.request.identifier

_   if responseNotificationRequestIdentifier == String.UNNotificationRequest.NormalLocalPush.rawValue ||
   _    responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithTrigger.rawValue ||
_      _responseNotificationRequestIdentifier == String.UNNotificationRequest.LocalPushWithCustomUI1.rawValue ||
__      responseNotificationRequestIdentifier_==_String.UNNotificationRequest.LocalPushWithCustomUI2.rawValue_{

_  _  _ let actionIdentifier_= response.actionIdentifier
_  _ _  switch_actionIdentifier_{
        case String.UNNotificationAction.Accept.rawValue:

        _   break
  _    _case_String.UNNotificationAction.Reject.rawValue:

  _   _     break
  _     case String.UNNotificationAction.Input.rawValue:

  __ _   _ _break
 _  _ _ case_UNNotificationDismissActionIdentifier:

 _      __  break
