2

I'm having an issue with HTTP requests. Everything is working fine in Ionic View, browser and Android, but not working on IOS. GET requests are working fine on IOS also. Any guesses, what can that be?

I can provide you with more information, just tell me what info do you need. Here's what I have in my package.json:

"dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/cloud-angular": "0.7.0",
    "@ionic/storage": "1.1.7",
    "@types/moment-timezone": "0.2.32",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "moment": "2.15.1",
    "moment-timezone": "0.5.7",
    "ng2-translate": "5.0.0",
    "rxjs": "^5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.0.0",
    "sw-toolbox": "^3.4.0",
    "typescript": "2.0.9"
  },

The backend receives blank body of a post request. Here's what I get back:

ERROR: {"_body":"{\"error\":\"Sign up error\",\"message\":{\"first_name\":[\"First Name cannot be blank.\"],\"last_name\":[\"Last Name cannot be blank.\"],\"email\":[\"Email cannot be blank.\"],\"device_id\":[\"Device Id cannot be blank.\"]}}","status":422,"ok":false,"statusText":"Bad Request","headers":{"Content-Type":["application/json; charset=UTF-8"],"Pragma":["no-cache"]},"type":2,"url":"http://app.EDITED"}

Feel free to ask anything and thank you for your help!

UPDATE: We moved our backend to HTTPS and now everything is working fine :)

Dmytro Garastovych
  • 335
  • 1
  • 2
  • 10
  • Show us your code please, can't debug what we can't see. – Ivar Reukers Jan 26 '17 at 12:19
  • Unfortunately, the contract doesn't allow me to do that. I just figured out that HTTPS POST requests in my code are working fine on IOS, so I guess the problem is only with using HTTP urls – Dmytro Garastovych Jan 26 '17 at 13:31
  • having similar problem, https solved the problem but this making me very uncomfortable. Posted a question over at ionic - https://forum.ionicframework.com/t/ionic2-rc5-body-removed-from-post-put-calls/77591 no response so far – Guy Nesher Jan 27 '17 at 13:30

1 Answers1

2

The official answer seems to be here:

https://techcrunch.com/2016/06/14/apple-will-require-https-connections-for-ios-apps-by-the-end-of-2016/

Apple simply decided to enforce the use of HTTPS. I suspect Cordova / Ionic are simply not handling this well at the moment (aka no error is thrown, it's not documented etc.)

Keep in mind that the safari inspector will show that data is being sent to the server - that is not correct all data sent is removed (entire body) in the iOS app (I lost a day on this).

As Dmytro Garastovych mentioned, the correct (and only) solution is to move to HTTPS

Guy Nesher
  • 1,385
  • 2
  • 14
  • 26