fbDidLogin的问题从未调用iOS [英] Problems with fbDidLogin never called iOS

查看:106
本文介绍了fbDidLogin的问题从未调用iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序保存access_token时遇到问题。问题是,当iPhone没有安装Facebook应用程序时,safari会处理这个并且没有问题。但是只要iPhone安装了Facebook应用程序。它只是不保存访问令牌,并在每次需要对Facebook做某事时打开Facebook应用程序。然后它说,你已经给了......许可...

I'm having problems with my app saving the access_token. The problem is, when an iPhone hasn't the Facebook app installed, safari will handle this and there is no problem. But as soon as the iPhone has the Facebook app installed. It Just isn't saving the access token and opens the Facebook app every time when it needs to do something with Facebook. It then says, you already have given .... permission...

这是我在viewdidload中做的第一次请求许可并收到来自用户的访问令牌默认值为:

This is what i'm doing to in the viewdidload to ask permission the first time and receive the access token from the user defaults:

facebook = [[Facebook alloc] initWithAppId:@"APPID"];


    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    NSArray* permissions =  [[NSArray arrayWithObjects:
                              @"read_stream", @"offline_access", nil] retain];

    if (![facebook isSessionValid]) {
        [facebook authorize:permissions delegate:self];
    }

这就是我在fbdidlogin中所做的事情:

This is what i'm doing in the fbdidlogin:

- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];   
}

但是对于某些方式,当Facebook应用程序获得控制权时这只是不起作用...每次视图加载时都会授权,再次加载。

But for some way when the Facebook app takes control this just doesn't work...It wil doe authorize every time when the view did load, loads again.

有没有人知道?

Thnx!

btw:我还有以下几行:

btw: I also have the following line:

(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { return [[controller facebook] handleOpenURL:url]; }


推荐答案

我找到了一个解决方法,即imo更好地使用Facebook应用程序。在Facebook.m文件中我改变了这个:

I've found a workaround, which imo is better the using the Facebook app. In the Facebook.m file i've changed this:

  [self authorizeWithFBAppAuth:YES safariAuth:YES];

到此

  [self authorizeWithFBAppAuth:NO safariAuth:YES]; 

在这种情况下,用户不会离开应用程序,并且所有内容都在弹出窗口内处理而不使用Facebook应用

In this case users don't leave the app, and everything is handled within the popup without using the Facebook app.

这篇关于fbDidLogin的问题从未调用iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆