Send Direct Push Notification - Swift

Source Code:

  
                         import Foundation

let headers = [
  "content-type": "application/x-www-form-urlencoded",
  "cache-control": "no-cache",
  "postman-token": "743940d0-680a-e188-8546-3236fa7556ae"
]

let postData = NSMutableData(data: "api_key=YOUR-API-KEY".data(using: String.Encoding.utf8)!)
postData.append("&device_token=YOUR-DEVICE-TOKEN".data(using: String.Encoding.utf8)!)
postData.append("&platform=iOS".data(using: String.Encoding.utf8)!)
postData.append("&msg_title=test message".data(using: String.Encoding.utf8)!)
postData.append("&destination_url=https://pushnotificationapi.com".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://send.pushnotificationapi.com/v1/push/send_direct")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()