ios - 您已经授权facebook、iOS
<p><p>现在我有一个 iOS 应用程序,它使用 facebook SDK 使用用户 facebook 帐户登录,显然你知道这一点。这是我用来做这些事情的代码。</p>
<pre><code>-(void)loginButtonClicked
{
FBSDKLoginManager *login = [ init];
fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
if ()
{
NSLog(@"result is:%@",result);
;
}
}
}];
}
- (void)fetchUserInfo
{
if ()
{
NSLog(@"Token is available : %@",[tokenString]);
[[ initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, email, birthday, bio, location, friends, hometown, friendlists"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"resultis:%@",result);
}
else
{
NSLog(@"Error %@",error);
}
}];
}
}
</code></pre>
<p>问题是当用户删除应用程序并安装然后再次登录时,facebook 登录对话框显示“您已经授权 {ApplicationName}”,用户必须单击确定才能返回我的应用程序。</p>
<p>我只希望他们只需要选项卡即可登录按钮,然后显示加载圈并成功。</p>
<p>有什么想法吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p><strong>选择 1</strong></p>
<p>如果你按下 <code>Login</code> 按钮,调用这个</p>
<p><strong>删除所有授予的权限</strong></p>
<pre><code>[[ initWithGraphPath:@"me/permissions" parameters:nil
HTTPMethod:@"DELETE"] startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
// call your login action and create the new session
;
}
}];
</code></pre>
<p><strong>选择 2</strong></p>
<p>如果你想清除当前 session 使用like</p>
<pre><code>-(void)loginButtonClicked
{
FBSDKLoginManager *login = [ init];
;
;
// then continue the same process
</code></pre>
<p><strong>更新</strong></p>
<p>如果你想绕过连接</p>
<pre><code> -(void)loginButtonClicked
{
if FBSDKAccessToken.currentAccessToken != nil
{
// already logged in with the requested permissions
}
else
{
// start the login process
}
}
</code></pre>
<p><strong> swift </strong></p>
<p><strong>删除所有授予的权限</strong></p>
<pre><code>FBSDKGraphRequest(graphPath: "me/permissions", parameters: nil,HTTPMethod: "DELETE").startWithCompletionHandler({(connection:FBSDKGraphRequestConnection, result: AnyObject, error: NSError) -> Void in
if error! {
// Process error
}
else if result.isCancelled {
// Handle cancellations
}
else {
// call your login action and create the new session
self.loginButtonClicked()
}
})
</code></pre>
<p><strong>选择 2</strong></p>
<p>如果你想清除当前 session 使用like</p>
<pre><code>func loginButtonClicked() {
var login: FBSDKLoginManager = FBSDKLoginManager()
login.logOut()
FBSDKAccessToken.currentAccessToken = nil
// then continue the same process
}
</code></pre>
<p><strong>更新</strong></p>
<pre><code>func loginButtonClicked() {
if FBSDKAccessToken.currentAccessToken != nil {
// already logged in with the requested permissions
}
else {
// start the login process
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 您已经授权facebook、iOS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37084850/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37084850/
</a>
</p>
页:
[1]