/* Directly copy the following to the login controller, bound to the story version of the login button, modify the marked red place can be used.
This is to use the phone number, and password to sign in.
*/
or the login button for the story version connection
-(ibaction) Login: (UIButton *) Sender {
afhttpsessionmanager *manager= [afhttpsessionmanager manager];
//Manager.requestserializer = [Afjsonrequestserializer serializer];
Manager. Responseserializer. Acceptablecontenttypes = [nsset setwithobjects:@ "Application/json", @ "Text/plain @ "Text/javascript", @ " text/json", @ "text/html", Nil];
[Manager. requestserializer setValue:@ " your Id" forhttpheaderfield:@ "X-lc-id" ];
[Manager. requestserializer setValue:@ " your key" forhttpheaderfield:@ "X-lc-key"];
[Manager. requestserializer setValue:@ "Application/json" forhttpheaderfield:@ " Content-type "];
nsstring *url =@ "Https://api.leancloud.cn/1.1/login";
// set whether to trust the server for invalid or expired SSL certificates. Default is no
//manager.securitypolicy.allowinvalidcertificates = YES;
// Set security authentication mode, default to afsslpinningmodenone
//manager.securitypolicy = [Afsecuritypolicy Policywithpinningmode:afsslpinningmodepublickey];
nsdictionary* parameters = @{@ "Mobilephonenumber": your phone number ,@ "password": your password. };
[Manager GET: url parameters:p arameters Progress:nil success: ^ ( Nsurlsessiondatatask * _nonnull task, ID _nullable responseobject) {
[self GOTONEXTVC];
} Failure: ^ (nsurlsessiondatatask * _nullable task, nserror * _nonnull error) {
NSLog(@ "%@", error);
}];
}
Leancloud User Login (Invoke API) tutorial