我的iOS应用程序经常在FUS期间被放弃到Facebook登录页面。我正在努力减少内存使用量,但我想保证即使我的应用程序被丢弃也能正常登录。
到目前为止,我无法让它发挥作用。当我按下“登录”按钮时,我的应用程序重新启动成功。我将网址传递到didFinishLaunchingWithOptions
以及appDelegate
的openURL,然后我调用[[FBSession alloc] initWithAppID]
,返回SessionCreated
状态的会话。
然后我打电话给
openActiveSessionWithPermissions:array allowLoginUI:NO completionHandler:^{stuff}
但是当我在活动会话上调用handleOpenURL
时,我的completionHandler
未被调用,我没有登录。
有人可以帮我解决如何让FB SDK准备好接受返回的URL吗?或者这甚至可能吗?
我正在使用FB SDK的v3.8.0。
答案 0 :(得分:1)
最后确定了正确的调用顺序。 authStr
是传递给didFinishLaunchingWithOptions
的网址。
bool IOSFacebookDriver::OpenAuthToken(const std::string &authStr)
{
NSString *authString = [NSString stringWithCString:authStr.c_str() encoding:NSUTF8StringEncoding];
NSURL *authURL = [NSURL URLWithString:authString];
FBAccessTokenData *token = [FBAccessTokenData createTokenFromFacebookURL:authURL appID:mNSAppId urlSchemeSuffix:[FBSession defaultUrlSchemeSuffix]];
bool tokenAccepted = [[FBSession activeSession] openFromAccessTokenData:token completionHandler:^(FBSession* session, FBSessionState state, NSError* error)
{<completion handler>};
}