我正在做一个基于iOS6的应用程序,社交Framework...it运行良好,但现在几个月后得到了一个奇怪的错误。
我将JSON Facebook数据导入到NSDictionary的NSLog是:
profiledictionary: {
error = {
code = 190;
"error_subcode" = 463;
message = "Error validating access token: Session has expired at unix time 1365610034. The current unix time is 1366032783.";
type = OAuthException;我的访问令牌似乎已经过期了,但是iOS6社交框架不是应该自动处理它吗?
有什么想法可以解决这个问题,同时避免将来出现这样的问题,这样我就可以安全地发布一个真正的应用程序了吗?
发布于 2013-04-17 04:40:15
最后让it...was检查NSDictionary是否有一个名为" error“的对象(在本例中是关于令牌过期的Facebook error),如果有,则调用一个方法来续订ACAccount:
if([self.profileDictionary objectForKey:@"error"]!=nil)
{
[self attemptRenewCredentials];
}
-(void)attemptRenewCredentials{
[self.accountStore renewCredentialsForAccount:(ACAccount *)self.facebookAccount completion:^(ACAccountCredentialRenewResult renewResult, NSError *error){
if(!error)
{
switch (renewResult) {
case ACAccountCredentialRenewResultRenewed:
NSLog(@"Good to go");
[self getFacebookAccount];
break;
case ACAccountCredentialRenewResultRejected:
NSLog(@"User declined permission");
break;
case ACAccountCredentialRenewResultFailed:
NSLog(@"non-user-initiated cancel, you may attempt to retry");
break;
default:
break;
}
}
else{
//handle error
NSLog(@"error from renew credentials%@",error);
}
}];
}https://stackoverflow.com/questions/16024658
复制相似问题