Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
目标C-登录后查看UIAlertView,如果ios的电子邮件id为空,则输入电子邮件id_Ios_Facebook_Email_Facebook Login - Fatal编程技术网

目标C-登录后查看UIAlertView,如果ios的电子邮件id为空,则输入电子邮件id

目标C-登录后查看UIAlertView,如果ios的电子邮件id为空,则输入电子邮件id,ios,facebook,email,facebook-login,Ios,Facebook,Email,Facebook Login,在我的代码中,如果用户是使用手机号码登录的,则在使用facebook登录时,我会得到电子邮件id的空值 因此,我希望uialertview输入电子邮件id并传递到我的api链接 - (void) fetchFacebookUserInfo { if ([FBSDKAccessToken currentAccessToken]) { [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"f

在我的代码中,如果用户是使用手机号码登录的,则在使用facebook登录时,我会得到电子邮件id的空值

因此,我希望uialertview输入电子邮件id并传递到我的api链接

- (void) fetchFacebookUserInfo {
if ([FBSDKAccessToken currentAccessToken]) {
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"first_name, last_name, picture.type(large), email, name, id, gender"} ]
     startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
         if (!error) {
             NSLog(@"fetched user:%@", result);

             NSLog(@"name:%@",[result objectForKey:@"name"]);
             NSLog(@"id:%@",[result objectForKey:@"id"]);
             NSLog(@"email:%@",[result objectForKey:@"email"]);

         if ([result objectForKey:@"email"]==NULL) {
// here i want uialertview for enter email id with validation and pass email id to my Callapi             
                 }
             } else {
                 [self CallApi:[result objectForKey:@"name"] :[result objectForKey:@"email"]];
             }
         }
     }];
  }
}

ViewController.h文件中定义strName

NSString *strName;
现在在您的方法中:-

    - (void) fetchFacebookUserInfo {
    if ([FBSDKAccessToken currentAccessToken]) {
        [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"first_name, last_name, picture.type(large), email, name, id, gender"} ]
         startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
             if (!error) {
                 NSLog(@"fetched user:%@", result);

                 NSLog(@"name:%@",[result objectForKey:@"name"]);
                 NSLog(@"id:%@",[result objectForKey:@"id"]);
                 NSLog(@"email:%@",[result objectForKey:@"email"]);

strName = [result objectForKey:@"name"];

             if ([result objectForKey:@"email"]==NULL) {
                UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:APP_NAME message:@"Please enter email id" delegate:self cancelButtonTitle:@"Submit" otherButtonTitles:@"Cancel", nil];
        alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
        [alertView show];
                     }
                 } else {
                     [self CallApi:strName:[result objectForKey:@"email"]];
                 }
             }
         }];
      }
    }
**确保已在接口(.h文件)中设置AlertViewDelegate,如下所示**

@interface yourViewController:UIViewController<UIAlertViewDelegate>

希望这能帮助你,让你开心。

你可以写下你的评论-UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“项目名称”消息:@“你的消息(请使用电子邮件地址登录)”代表:自我取消按钮:@“确定”其他按钮:无,无];[警报显示];但我不想强迫他用电子邮件id重新登录。。。因此,我最好让他输入电子邮件id,用AlertViewStyle显示alert,而不是dear。如果用户未通过电子邮件注册,或者用户未在其个人资料中提供电子邮件id,thn FBSDK将不向我们提供。FBSDK将以nil的形式发送该参数。是的,这正是为什么我希望要求用户手动输入电子邮件id,而不是使用输入文本字段设置警报。我的Web服务类似于[self callYourWebService:name:[alertViewAtIndex:0]。text];根据您的编码,我从用户处手动收到电子邮件,但问题只是如何在此Web服务上传递facebook名称…调试程序显示名称字段为空且[alertViewAtIndex:0]。文本显示输入的电子邮件ID谢谢您非常感谢…现在我知道了…:)你也可以帮我。
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if(buttonIndex == 0){
        if(![CommonMethod validateEmailWithString:[alertView textFieldAtIndex:0].text]){
            NsLog(@"Please enter valid email address");
        }else{
             [self callYourWebService:strName:[alertViewAtIndex:0].text];
        }
    }
}