Leancloud User Login (Invoke API) tutorial

Source: Internet
Author: User

/* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.