Swift

Swift NSURLSession

import Foundation
let headers = [
"content-type": "application/json"
]
let parameters = [
"token": "c2a0b6221c5dd55ceb09ae1f74e46521756d",
"priority ": 0,
"application": "2",
"sleep": 0,
"globalmessage": "",
"globalmedia": "",
"data": [
[
"number": "1212",
"message": "Test"
]
]
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://pickyassist.com/app/api/v2/push")! 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()