ios facebook 登录给我已经授权这个应用程序而不自动返回到应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10888582/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
facebook login give me already authorized this app without automatic returning to the app
提问by Omar Freewan
My app should implement login with facebook but I have noticed that every time I want to login the facebook tell me you are already authorize this app , the question if I already authorized the app the facebook should return automatically without pressing the okey button as I saw in other applications ?
我的应用程序应该实现使用 facebook 登录,但我注意到每次我想登录 facebook 时都告诉我你已经授权了这个应用程序,如果我已经授权了这个应用程序,facebook 应该自动返回而不按我看到的 okey 按钮在其他应用程序中?
see the attached image
见附件图片
采纳答案by Omar Freewan
I fixed my problem by doing the following steps :
1- login to your facebook as admin to your app.
2- go to https://developers.facebook.com/apps/YOUR_FACEBOOK_APP_ID/summary.
3- go to settings> basic> Native IOS app
4- set the Configured for iOS SSO:to enabled
我通过执行以下步骤解决了我的问题:
1- 以管理员身份登录到您的 Facebook 到您的应用程序。
2- 去https://developers.facebook.com/apps/YOUR_FACEBOOK_APP_ID/summary。
3- 转到设置>基本> 本机 IOS 应用程序
4- 设置为 iOS SSO 配置:启用
回答by PANKAJ VERMA
In iOS/Android the FBAccessToken's expiration time is up to 60 days. When you do FBLogin in your app you get the access token. once you get the token you should not do login again(otherwise you will be prompted already authorized this appsince your app has already been given an access token earlier which is not expired ). You should reuse the unexpired access token.
在 iOS/Android 中,FBAccessToken 的过期时间最长为 60 天。当您在应用程序中执行 FBLogin 时,您将获得访问令牌。获得令牌后,您不应再次登录(否则,系统会提示您已授权此应用程序,因为您的应用程序之前已经获得了未过期的访问令牌)。您应该重用未过期的访问令牌。
Like this :
像这样 :
if FBSDKAccessToken.currentAccessToken() != nil {
print(FBSDKAccessToken.currentAccessToken().userID)
print(currentAccessToken().tokenString)
//OR call the *FBGraphRequest*
}
Note: for in-App browser login (SVC: Safari View Controller)
注意:用于应用内浏览器登录(SVC:Safari View Controller)
see more: https://developers.facebook.com/blog/post/2015/10/29/Facebook-Login-iOS9/and https://developers.facebook.com/docs/reference/ios/4.9/class/FBSDKLoginManager/
查看更多:https: //developers.facebook.com/blog/post/2015/10/29/Facebook-Login-iOS9/和 https://developers.facebook.com/docs/reference/ios/4.9/class/ FBSDK登录管理器/
回答by Shobhakar Tiwari
As this Question is already answered , but i would like to add another helpful answer for Swift 3.0
:
由于这个问题已经回答,但我想添加另一个有用的答案Swift 3.0
:
While using FB Login in Swift , i having issue and i previously did this way:
在 Swift 中使用 FB Login 时,我遇到了问题,我以前是这样做的:
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.loginBehavior = .systemAccount
As this uses , System account to check user is authorized for login or not . Unless you logout and login through different user , application shows same "Already authorized" message in place of Fresh login . So i used this way and this trick does the work :
由于这使用,系统帐户检查用户是否被授权登录。除非您注销并通过不同的用户登录,否则应用程序会显示相同的“已授权”消息来代替 Fresh login。所以我用这种方式,这个技巧可以工作:
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.loginBehavior = .web.
This show Login Screen after logout. Hope this helps to solve this issue.
注销后显示登录屏幕。希望这有助于解决这个问题。
Feel free to comment . Thanks.
随意评论。谢谢。
回答by Amal T S
You should check if there is a current session before logging in with FBSDKLoginManager
. Do not use [loginManager logout]
before logging in.
在使用 登录之前,您应该检查是否有当前会话FBSDKLoginManager
。[loginManager logout]
登录前请勿使用。
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
// Now get details using graphpath.
} else {
// login with permissions using FBSDKLoginManager and get details using graphpath in completion
}
回答by Matt Hudson
You need to make sure that your app has the proper URL Prefix in your Build Settings. Also make sure that the URL Prefix matches your Facebook ID/URL Prefix in the Facebook developer app.
您需要确保您的应用在构建设置中具有正确的 URL 前缀。还要确保 URL 前缀与您在 Facebook 开发者应用中的 Facebook ID/URL 前缀相匹配。
Edit:Your issue is probably that the access_token is expiring so it's have to re-ask for permissions.
编辑:您的问题可能是 access_token 即将到期,因此必须重新请求权限。
This will happen if your application did not request offline_access permissions. In the newer SDK offline_access is deprecated and you now have to extend the access_token.
如果您的应用程序没有请求 offline_access 权限,就会发生这种情况。在较新的 SDK 中,不推荐使用 offline_access,您现在必须扩展 access_token。
See this link: https://developers.facebook.com/docs/mobile/ios/build/#extend_token
请参阅此链接:https: //developers.facebook.com/docs/mobile/ios/build/#extend_token
回答by Florian Widtmann
There is a open bug at facebook.com
facebook.com 上有一个未解决的错误
https://developers.facebook.com/bugs/190389531089978
https://developers.facebook.com/bugs/190389531089978
But the bug only appears at android, ios works fine.
但是这个bug只出现在android上,ios运行正常。
(btw. same behavior in the foursquare and spotify android app - check it out)
(顺便说一句。在foursquare和spotify android应用程序中的相同行为 - 检查一下)
回答by Augustin A
Run your iOS FB application into device not simulator it works fine, and didn't shows the already authorized screen. Thank you.
将您的 iOS FB 应用程序运行到设备而不是模拟器中,它工作正常,并且没有显示已授权的屏幕。谢谢你。