2011-10-11 19 views
2

我正在使用Sharekit for Facebook与Facebook Graph API共享。我试图找到最新的,最新的代码(github上的troppoli看起来相当新)。使用sharekit注销Twitter可以正常工作:[SHK logoutOfService:@“SHKTwitter”];但Facebook的同一行[SHK logoutOfService:@“SHKFacebook”]会产生不同的结果。Sharekit for Facebook(Graph API版本)注销方法未完全注销或取消对用户的授权

当我重新登录时,登录屏幕不显示。相反,屏幕上显示以下文字:“您已经授权...按下确定继续。”然后在屏幕底部“登录为...”和“注销”。但用户应该已经注销。

更糟的是,如果我按“好”按钮继续,我得到的错误:“该操作无法完成(NSURLErrorDomain错误-999)。

我想我可能需要调整ShareKit使这项工作,但我讨厌这样做。有没有其他人遇到这个?

回答

1

我很确定这与新的Facebook Single-Sign-On(SSO)有关。如果用户安装了Facebook 3.2.3或更高版本,或者如果Safari在设备(或模拟器)上,则授权现在在应用程序的外部进行。将发布更多,因为我找到它。

编辑:除了NSURL错误,似乎这是新的Facebook SSO的预期行为。在用户注销应用程序后,如果用户登录到其他应用程序等,用户应该保持伪登录/注销状态 - 现在全部连接。要真正注销Facebook(说,以别人身份登录等),似乎用户需要单击授权web视图上的注销链接,以显示他们何时在应用中“注销”了Facebook。我可能是错的,但我对此很肯定。

除了上述,我确实找到了一种摆脱NSURL错误的方法,这使得事情变得更好,并且更加可口。见How Do I Fix NSURLErrorDomain Error -999 in iPhone

欲了解更多的新的Facebook SSO:从Facebook iOS Tutorial

摘录(见尤其是最后一段):

Step 3: Implementing Single Sign-On (SSO)

One of the most compelling features of the iOS SDK is Single-Sign-On (SSO). SSO lets users sign into your app using their Facebook identity. If they are already signed into the Facebook iOS app on their device they do not have to even type a username and password. Further, because they are signing to your app with their Facebook identity, you can get permission from the user to access to their profile information and social graph.

SSO primarily works by redirecting the user to the Facebook app on her device. Since the user is already logged into Facebook, they will not need to enter their username and password to identify themselves. They will see the auth dialog with the permissions that your app has asked for and if they allow then they will be redirected to your app with the appropriate access_token.

Developers should be aware that Facebook SSO will behave slightly different depending on what is installed on the user's device. This is what happens in certain configurations:

If the app is running in a version of iOS that supports multitasking, and if the device has the Facebook app of version 3.2.3 or greater installed, the SDK attempts to open the authorization dialog within the Facebook app. After the user grants or declines the authorization, the Facebook app redirects back to the calling app, passing the authorization token, expiration, and any other parameters the Facebook OAuth server may return.

If the device is running in a version of iOS that supports multitasking, but it doesn't have the Facebook app of version 3.2.3 or greater installed, the SDK will open the authorization dialog in Safari. After the user grants or revokes the authorization, Safari redirects back to the calling app. Similar to the Facebook app based authorization, this allows multiple apps to share the same Facebook user access_token through the Safari cookie.

If the app is running a version of iOS that does not support multitasking, the SDK uses the old mechanism of popping up an inline UIWebView, prompting the user to log in and grant access. The FBSessionDelegate is a callback interface that your app should implement: The delegate's methods will be invoked when the app successful logs in or logs out. Read the iOS SDK documentation for more details on this delegate.

...

When the user wants to stop using Facebook integration with your app, you can call the logout method to clear the app state and make a server request to invalidate the current access_token.

[facebook logout:self]; You may implement the fbDidLogout method of the FBSessionDelegate protocol to handle any post-logout actions you wish to take.

Note that logging out will not revoke your application's permissions, but will simply clear your application's access_token. If a user that has previously logged out of your app returns, they will simply see a notification that they are logging into your app, not a notification to grant permissions. To modify or revoke an application's permissions, the user can visit the "Applications, Games, and Websites" tab of their Facebook privacy settings dashboard. You can also revoke an app's permissions programmatically using a Graph API call.

希望这有助于让你若有发现什么不同的我知道。

2

你需要确保你在你的info.plist中正确设置了URL方案在你的info.plist中,确保你的CFBundleURLTypes设置为Facebook:

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
     <key>CFBundleURLName</key> 
     <string></string> 
     <key>CFBundleURLSchemes</key> 
     <array> 
      <string>fb{app_id}</string> 
     </array> 
    </dict> 
</array> 

替换{ app_id}与您的Facebook应用程序ID。

您还需要在您的应用程序委托添加一个处理程序回调响应用户通过移动Safari浏览器认证之后:

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

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication 
     annotation:(id)annotation{ 
    return [SHKFacebook handleOpenURL:url]; 
} 

这些变化修复了这个问题对我来说。

+0

感谢您的答复马克。我的第一个问题是 - 您目前是否在使用oAuth 2.0和Facebook Graph API?我在常规的FBConnect中完美地工作,这只是更新(并使用Sharekit来这样做),我有这种注销问题。我确实已经在应用程序委托中正确设置了处理程序。我也有plist成立......但我还有一些额外的问题给你。我的应用程序不是一个iPad应用程序,而不是CFBundleURLTypes/CFBundleURLName/CFBundleURLSchemes,我的plist有以下关键字:URL类型/ URL标识符/ URL Schemes .... – SAHM

+0

我不能改变这个(我知道的),但我我想我已经读过,在CF名字的实际plist中它仍然是一样的。这是否正确?另外,我在不同的例子中看到了这一点,有和没有URL标识符/ CFBundleURLName。我尝试了两种方法,仍然得到相同的结果。无论如何,我很想听听你对这个问题有更多的想法。再次感谢。 – SAHM

+0

标记您的答案,因为它是很好的信息,并希望可以帮助某人。在这一点上,没有解决这个问题。 – SAHM