打开facebook对话框进行身份验证,而不是在iphone中安装facebook应用程序?

打开facebook对话框进行身份验证,而不是在iphone中安装facebook应用程序?,iphone,objective-c,ios,Iphone,Objective C,Ios,我想制作一个应用程序,要求在对话中验证facebook登录,无论facebook应用程序是否安装在iphone中。如果我注销facebook,那么它应该从facebook注销。我已将facebook ios sdk用于facebook api我的代码如下: - (void)viewDidLoad { _facebook=[[Facebook alloc] initWithAppId:appId andDelegate:self]; self.navigationControll

我想制作一个应用程序,要求在对话中验证facebook登录,无论facebook应用程序是否安装在iphone中。如果我注销facebook,那么它应该从facebook注销。我已将facebook ios sdk用于facebook api我的代码如下:

- (void)viewDidLoad
{
    _facebook=[[Facebook alloc] initWithAppId:appId andDelegate:self];

    self.navigationController.navigationBarHidden = YES;
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"])
    {
        _facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        _facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    [super viewDidLoad];
}
//点击登录按钮

-(IBAction)Login
{
    NSLog(@"login called");

    if (![self connected])
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Connection" message:@"Internet is not Connected" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];[alert release];
    }
    else
    {
        if (suggestion==nil)
        {
            suggestion=[[Suggestions alloc] initWithNibName:@"Suggestions" bundle:nil];
        }
        [suggestion setReqFlg:YES];

        if (![_facebook isSessionValid]) 
        {
            NSLog(@"sesssion invalid u have to login...");
            [_facebook authorize:nil];
        }
        else
        {
            NSLog(@"valid and going on next page called graph API ");      

            [_facebook requestWithGraphPath:@"me?fields=id,name" andDelegate:self];
            suggestion.parentView=self;
            [self.navigationController pushViewController:suggestion animated:YES];
        }
    }
}



- (void)fbDidLogin
{
    NSLog(@"facebook did first login..");
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[_facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[_facebook expirationDate] forKey:@"FBExpirationDateKey"];  
    [defaults synchronize];
    NSLog(@"called gtraph from login in facebook ");
    [_facebook requestWithGraphPath:@"me?fields=id" andDelegate:self];
    if (suggestion==nil)
    {
        suggestion=[[Suggestions alloc] initWithNibName:@"Suggestions" bundle:nil];
    }
    suggestion.parentView=self;
    [self.navigationController pushViewController:suggestion animated:YES];
}

- (void)fbDidLogout
{
    NSLog(@"logout");
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults removeObjectForKey:@"FBAccessTokenKey"];
    [defaults removeObjectForKey:@"FBExpirationDateKey"];
    [defaults removeObjectForKey:@"FBUserId"];

    [defaults synchronize];
}
我是否必须在facebook.m文件中进行更改,或者有其他方法进行更改。每次单击“登录”按钮时,如果facebook已注销,则应显示“facebook登录”对话框,如果facebook已登录,则应导航到下一个视图。不要打开iphone中安装的用于登录的facebook应用程序

给出你的评论或答案,我非常需要。
谢谢你

进入facebook.m文件,用FBAppAuth搜索,你会得到3_4的结果,如:-

-(IBAction)Login
{
    NSLog(@"login called");

    if (![self connected])
    {
        UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Connection" message:@"Internet is not Connected" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];[alert release];
    }
    else
    {
        if (suggestion==nil)
        {
            suggestion=[[Suggestions alloc] initWithNibName:@"Suggestions" bundle:nil];
        }
        [suggestion setReqFlg:YES];

        if (![_facebook isSessionValid]) 
        {
            NSLog(@"sesssion invalid u have to login...");
            [_facebook authorize:nil];
        }
        else
        {
            NSLog(@"valid and going on next page called graph API ");      

            [_facebook requestWithGraphPath:@"me?fields=id,name" andDelegate:self];
            suggestion.parentView=self;
            [self.navigationController pushViewController:suggestion animated:YES];
        }
    }
}



- (void)fbDidLogin
{
    NSLog(@"facebook did first login..");
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[_facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[_facebook expirationDate] forKey:@"FBExpirationDateKey"];  
    [defaults synchronize];
    NSLog(@"called gtraph from login in facebook ");
    [_facebook requestWithGraphPath:@"me?fields=id" andDelegate:self];
    if (suggestion==nil)
    {
        suggestion=[[Suggestions alloc] initWithNibName:@"Suggestions" bundle:nil];
    }
    suggestion.parentView=self;
    [self.navigationController pushViewController:suggestion animated:YES];
}

- (void)fbDidLogout
{
    NSLog(@"logout");
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    [defaults removeObjectForKey:@"FBAccessTokenKey"];
    [defaults removeObjectForKey:@"FBExpirationDateKey"];
    [defaults removeObjectForKey:@"FBUserId"];

    [defaults synchronize];
}
 [self authorizeWithFBAppAuth:YES safariAuth:YES];
只需将“是”更改为“否”,如:-

 [self authorizeWithFBAppAuth:NO safariAuth:NO];
仅在facebook.m中进行更改,并在单击loginButton时编译并运行您的登录对话框:)

编辑

我的应用程序登录页面上有我的登录对话框


如果我单击“登录”按钮,它将转到安装在iphone中的facebook应用程序进行身份验证。我想在“facebook”对话框中显示它。我非常确定苹果不允许你从自己的应用程序登录facebook,而是使用facebook应用程序登录。我不想使用它,我想使用facebook对话框登录,而不是我拥有的facebook应用程序Nitin Gohel先生,这是用于safari而不是facebook应用程序如果你的iphone上安装了facebook应用程序,那么它将不会打开用于身份验证的对话框。这是为了我尝试此代码并在自己的工作中实现,并且工作正常:--阅读完整方法authorizewithFBAppAuth:NO或YesPS安装facebook应用程序在您的idevice上,然后在您的设备上检查它。查看我的可编辑答案我只需上传我的屏幕截图并在facebook.m文件中更改每个authorizeWithfBapAuth=NO不仅在一种方法中,而且在facebook.mNo不,我也使用此方法注销:-[[objappdelegate facebook]注销];