I've been struggling with this issue for a couple of days now but still haven't found a solution. Basically, I make a POST NSURLRequest with Alamofire and send user and password as json in the request body so that I can receive a session token in the response:
let mutableURLRequest = NSMutableURLRequest(URL: NSURL(string: path)!)
mutableURLRequest.HTTPMethod = "POST"
mutableURLRequest.setValue("application/json", forHTTPHeaderField:"Content-Type")
switch self {
case AuthenticateApp:
let parameters = [
"method": "login",
"params": [
"user": user,
"password": pass
]
]
mutableURLRequest.HTTPBody = try! NSJSONSerialization.dataWithJSONObject(parameters, options: [])
case ...
My problem is that the request is only successful on iphone 5s and above, while I get an error when running the same request on iphone 4s or 5:
{
"error" : "Login or password was invalid.",
"code" : 1
}
I have tried printing and checking multiple thing but haven't found anything that would point me to the source of the issue. I've tried the solution given in NSHTTPURLResponse different on iPhone 5 vs 5s and added the code below to the request but it didn't help:
mutableURLRequest.setValue("gzip", forHTTPHeaderField:"Content-Encoding")
I've printed the response header fields for iphone 5 and 5s and found no differences. It seems as if the server does not receive the username and password in the correct format? The username contains the "@" symbol. Could this be responsible for the problem?
UPDATE:
A good Samaritan from Apple's developer forum pointed me in the right direction – the requests made from a 32-bit devices are for some reason rejected by the server. I've no idea how to fix this at this point...