Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var theJSONText = ""
  2. dataToSend["trigger"] = ""
  3. dataToSend["gcm"] = ""
  4. dataToSend["client"] = "ios"
  5. dataToSend["deviceId"] =
  6. UIDevice.current.identifierForVendor!.uuidString
  7. dataToSend["deviceName"] = UIDevice.current.name
  8. dataToSend["login_source"] = loginSource
  9. dataToSend["lastsync"] = 0
  10. dataToSend["rows"] = []
  11. dataToSend["urlencode"] = true
  12. if let rows = rows {
  13. for row in rows {
  14. if row.syncRequired == 1 {
  15. rowsToSync.append(row)
  16. }
  17. }
  18. }
  19. rowsToSync.resultType = NSDictionary
  20. dataToSend["rows"] = rowsToSync
  21. print( dataToSend["rows"])
  22. if let theJSONData = try? JSONSerialization.data(
  23. withJSONObject: dataToSend,
  24. options: []) {
  25. theJSONText = String(data: theJSONData,
  26. encoding: .ascii)!
  27. print("JSON string = (theJSONText)")
  28. }
  29. params["data"] = theJSONText
  30. APIService.shared.syncUser(params: params) { (success, data, error) in
  31. if success{
  32. print("success in global sync")
  33. rows = data?.rows
  34. }else {
  35. print("failure in global sync")
  36. print(error?.errorMessage)
  37. }
  38. }
Add Comment
Please, Sign In to add comment