Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- return nil
- }
- func getDeviceInfo(_ hostToUse: String,deviceID: String, completion : @escaping (_ success: Bool, _ json: AnyObject? )->Void ) -> Void {
- var request = URLRequest(url: URL(string: "http://urlHeret")!)
- request.httpMethod = "POST"
- request.timeoutInterval = 120.0
- var postString = "data={"deviceID": "****"}"
- postString = postString.replacingOccurrences(of: " ", with: "")
- request.httpBody = postString.data(using: .utf8)
- let task = URLSession.shared.dataTask(with: request) { data, response, error in
- guard let data = data, error == nil else {
- completion(false, nil )
- return
- }
- let result = self.convertDataToDictionary(data: data)
- if result!["result"] as! Bool == false {
- completion(false, result as AnyObject? )
- } else {
- completion(true, result as AnyObject? )
- }
- }
- task.resume()
- }
Add Comment
Please, Sign In to add comment