ios - FBSDKAccessToken currentAccessToken 为 nil
<p><p>代码:</p>
<pre><code>self.accountStore = [init];
ACAccountType *FBaccountType= [self.accountStore
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSString *appID = @"356775877779749"; //The app ID issued by Facebook
NSDictionary *dictFB = [NSDictionary dictionaryWithObjectsAndKeys:
appID, ACFacebookAppIdKey,
@[@"email"], ACFacebookPermissionsKey,
nil];
[self.accountStore requestAccessToAccountsWithType:FBaccountType options:dictFB completion:
^(BOOL granted, NSError *e) {
if (granted)
{
NSArray *accounts = ;
//it will always be the last object with single sign on
self.facebookAccount = ;
ACAccountCredential *facebookCredential = ;
NSString *accessToken = ;
NSLog(@"Successfully logged in. Access Token: %@", accessToken);
FBSDKAccessToken* AccessToken = ;
NSLog(@"%@", AccessToken);
;
} else {
//Failed
NSLog(@"error getting permission: %@",e);
}
}];
</code></pre>
<p>我使用上面的代码登录。出于某种原因,<code>NSString *accessToken = </code> 正确存储了访问 token ,但 <code>FBSDKAccessToken* AccessToken = </code> 没有。</p>
<p>有什么方法可以将 <code>NSString *accessToken</code> 转换为 <code>FBSDKAccessToken</code>?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我遇到了类似的问题,这是由于我没有在 <code>FBSDKProfile</code> 上设置 <code>enableUpdatesOnAccessTokenChange</code>。不知道为什么它默认不这样做。</p>
<pre><code>;
</code></pre>
<p>或者对于 swift </p>
<pre><code>FBSDKProfile.enableUpdatesOnAccessTokenChange(true)
</code></pre></p>
<p style="font-size: 20px;">关于ios - FBSDKAccessToken currentAccessToken 为 nil,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/35171416/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/35171416/
</a>
</p>
页:
[1]