gpt4 book ai didi

ios - Facebook SDK FBSession 代码不适用于 Swift

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:48:31 26 4
gpt4 key购买 nike

尝试在 Swift 中实现这个 Objective C 代码:

    // Whenever a person opens the app, check for a cached session
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {

// If there's one, just open the session silently, without showing the user the login UI
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile"]
allowLoginUI:NO
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
[self sessionStateChanged:session state:state error:error];
}];

但是在这一行中 FBSession.activeSession.state.value 出现错误:

if FBSession.activeSession.state.value == FBSessionStateCreatedTokenLoaded.value {
FBSession.openActiveSessionWithReadPermissions(self.facebookReadPermissions, allowLoginUI: true, completionHandler: {(session, state, error) -> Void in
self.sessionStateChanged(session, state: state, error: error)
})
}

请帮忙。

最佳答案

用这个改变你的第一个 if 语句

    if(FBSession.activeSession().state == FBSessionState.CreatedTokenLoaded)
{

}

关于ios - Facebook SDK FBSession 代码不适用于 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24995192/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com