My friend coded server and I tried to connect my app to the server. but now I'm in problem with connecting the server. After searching, I found lots of things. (how to get access token, use SHA256, Alamofire library,,,etc)
But it is difficult to see our API and code the swift app. I hope somebody helps good example for start to connect server with my app.
below is our API for signup.
// ch-----.co.kr:8081/api/user/createAccount
Request Type: POST, json/urlencoded
Parameter
userId : user account name
userPassword : user password for account
userEmail : user email for account
when success,
{ "meta": "createAccount", "data": "success" }
when fail,
{ "meta": "createAccount", "data": "failed" }
hope to use alamofire and get the first step example. please..
and code is in part of my register page.
//MARK:- Infoamation
@IBOutlet weak var username: UITextField!
@IBOutlet weak var email: UITextField!
@IBOutlet weak var password: UITextField!
@IBOutlet weak var passwordRe: UITextField!
@IBOutlet weak var admitUseRule: UISwitch!
@IBOutlet weak var admitPrivacyRule: UISwitch!
//register action
@IBAction func registerAction(sender: AnyObject) {
let usernameText = username.text
let emailText = email.text
let passwordText = password.text
let passwordReText = passwordRe.text
//check if filling out ID
guard usernameText?.isEmpty != true else{
displayAlert("아이디를 입력하세요")
return
}
//check if the id counts less than 20
guard usernameText?.characters.count < 20 else{
displayAlert("아이디를 20자 이내로 입력하세요")
return
}
//check iD validation
guard isValidID(self.username.text!) != false else{
displayAlert("아이디를 영어와 숫자의 조합으로 입력하세요")
return
}
//check if filling out email
guard emailText?.isEmpty != true else{
displayAlert("이메일 입력하세요")
return
}
//check email validation
let validLogin = isValidEmail(self.email.text!)
guard validLogin != false else {
displayAlert("정확한 이메일을 입력하세요")
return
}
//check if the user fill out password
guard passwordText?.isEmpty != true else {
displayAlert("비밀번호를 입력하세요")
return
}
//check the password is same
guard passwordText == passwordReText else {
displayAlert("입력한 비밀번호가 같지 않습니다")
return
}
//admit for useRule
guard admitUseRule.on == true else {
displayAlert("이용약관에 동의해주세요")
return
}
//admit for privacyRule
guard admitPrivacyRule.on == true else {
displayAlert("개인정보 취급 방침에 동의해주세요")
return
}
//connect server
////////////////////
dismissViewControllerAnimated(true, completion: nil)
}