Guest User

Untitled

a guest
Oct 19th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. return nil
  2. }
  3.  
  4. func getDeviceInfo(_ hostToUse: String,deviceID: String, completion : @escaping (_ success: Bool, _ json: AnyObject? )->Void ) -> Void {
  5. var request = URLRequest(url: URL(string: "http://urlHeret")!)
  6. request.httpMethod = "POST"
  7. request.timeoutInterval = 120.0
  8.  
  9.  
  10. var postString = "data={"deviceID": "****"}"
  11. postString = postString.replacingOccurrences(of: " ", with: "")
  12.  
  13. request.httpBody = postString.data(using: .utf8)
  14. let task = URLSession.shared.dataTask(with: request) { data, response, error in
  15. guard let data = data, error == nil else {
  16. completion(false, nil )
  17. return
  18. }
  19.  
  20. let result = self.convertDataToDictionary(data: data)
  21. if result!["result"] as! Bool == false {
  22. completion(false, result as AnyObject? )
  23. } else {
  24. completion(true, result as AnyObject? )
  25. }
  26. }
  27. task.resume()
  28. }
Add Comment
Please, Sign In to add comment