I have a curl post that I'd like to turn into a http url request in swift:
curl post (command line):
curl -X POST --header "Content-Type:application/json" --header "Authorization:key=SERVER_KEY" "https://gcm-http.googleapis.com/gcm/send" --data-ascii '{"to":"DEVICE_TOKEN","data":{"uid":"USER_ID"},"priority":10,"notification":{"body":"Hello","badge":"2"}}'
http request (swift):
var request = URLRequest(url: URL(string: globalClass.getAppDelegate().global.sendUrl)!)
request.httpMethod = "POST"
var bodyData:String!
bodyData = "title=\(title)&body=\(message)&user_id=\(user_id)"
request.httpBody = bodyData.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request)
how do I put the data part into the bodyData of the http request?
"data":{"uid":"USER_ID"}
I don't know how to form it since it is a nested structure.