简体   繁体   English

GIgya本机登录,无需使用Facebook和Twitter帐户

[英]GIgya Native Login without using Facebook and Twitter Account

Following code that i am using to login but i am getting a Null response 以下代码用于登录,但我得到了Null响应

- (IBAction) signInPressed : (id)sender

{

[super signInPressed:sender];


 NSLog(@"ACCLoginViewController_iPhone Sign-IN Pressed");



//Load the Gigya login UI component, passing this View Controller as a delegate.



 GSRequest *request  =  [GSRequest requestForMethod:@"accounts.login"];



[request.parameters setObject:self.emailField.text forKey:@"loginID"];



 [request.parameters setObject:self.passwordField.text forKey:@"password"];



 request.parameters[@"loginID"] = @"email";



[request sendWithResponseHandler:^(GSResponse *response, NSError *error) {


if (!error) {

NSLog(@"the resposne = %@",response);

 }

 else {

  // Check the error code according to the GSErrorCode enum, and handle it.


 NSLog(@"the Error = %@",error.description);


 }

 }];



  //  [self loadTabbar];


}

Typically, we would suggest that you download Gigya's demo XCode project from their iOS documentation and compare what you are doing differently from the demo project. 通常,我们建议您从其iOS文档中下载Gigya的演示XCode项目 ,并比较您与该演示项目有何不同之处。 But I believe that the demo project is only set up to do socialLogin and you look as if you are attempting to implement Registration-as-a-Service. 但是我相信该演示项目仅是为了进行socialLogin而设置的,看起来您似乎在尝试实现“注册即服务”。

Unfortunately, there isn't enough information provided to really help you diagnose your issue. 不幸的是,没有提供足够的信息来真正帮助您诊断问题。 You will need to provide the code used to initialize the Gigya SDK and any stack trace logs with errors that are being generated. 您将需要提供用于初始化Gigya SDK的代码以及所有带有正在生成的错误的堆栈跟踪日志。

Additionally, I realize here that you are not using Facebook Native and Twitter logins but I will provide the following feedback regardless, so that you don't run into these problems in the future should you choose to. 此外,我在这里意识到您没有使用Facebook本机和Twitter登录,但是无论如何我都会提供以下反馈,以便您以后选择时不会遇到这些问题。

There are some very specific "gotchas" when implementing Facebook login with iOS. 使用iOS实现Facebook登录时,存在一些非常具体的“陷阱”。 Facebook requires that Native Mobile applications integrate and only use their native Facebook login flow. Facebook要求本机移动应用程序集成并且只能使用其本机Facebook登录流程。 If you are implementing Gigya with Facebook, you must follow Gigya's documentation on how to enable Facebook Native login so that the Gigya iOS SDK can properly bridge to it. 如果要通过Facebook实现Gigya,则必须遵循Gigya的文档以了解如何启用Facebook本机登录,以便Gigya iOS SDK可以正确地与其连接。

In the app delegate you'll need the following. 在应用程序委托中,您需要以下内容。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [Gigya initWithAPIKey:@"[api key goes here"];
    return YES;
}

In the view controller I'm currently using this code which is working for me. 在视图控制器中,我当前正在使用适合我的代码。

- (void)loginUser:(NSString*)email withPassword:(NSString*)password
{
    if (![[Gigya session] isValid]) {
        GSRequest *request = [GSRequest requestForMethod:@"accounts.login"];
        request.parameters[@"loginID"] = email;
        request.parameters[@"password"] = password;

        [request sendWithResponseHandler:^(GSResponse *response, NSError *error) {
            if (!error) {
                NSLog(@"response: %@", response);
                NSString* sessionToken = response[@"sessionInfo"][@"sessionToken"];
                NSString* sessionSecret = response[@"sessionInfo"][@"sessionSecret"];
                GSSession* gigyaSession = [[GSSession alloc] initWithSessionToken:sessionToken secret:sessionSecret];
                [Gigya setSession:gigyaSession];
            }
            else {
                NSLog(@"error: %@", error);
            }
        }];
    }
    else {
        NSLog(@"Already logged in. Logout first.");
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM