本文介绍了facebook unity sdk 7.0.2-重新打开应用程序时FB.IsLoggedIn返回false,但仍应登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在升级到Unity FB SDK的7.X版本之前,FB.IsLoggedIn将在FB.Init之后返回true.现在,它返回false,每次您都必须重新登录.
Prior to upgrading to the 7.X version of the Unity FB SDK, FB.IsLoggedIn would return true after FB.Init. Now, it is returning false and you have to do a new login every time.
这似乎是个错误.
我正在使用Unity 5.1.1p4,并正在为Android进行构建.我还没有尝试过iOS.
I'm on Unity 5.1.1p4 and building for Android. I haven't tried iOS yet.
复制步骤:
- 启动应用,登录FB
- 关闭应用
- 再次启动应用程序,您将不会自动登录到FB(FB.IsLoggedIn为false)
预期行为:
如果您以前登录过,FB.IsLoggedIn应该为true.这是以前的工作方式.
FB.IsLoggedIn should be true if you were previously logged in. This is how it worked before.
推荐答案
在 FBUnityInterface.mm
中:
-
添加到-
(id)init
:
[[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:NULL];
替换为-(void)configureAppId
:
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete userData:@{} requestId:0];
具有:
if ([FBSDKAccessToken currentAccessToken]) {
FBSDKAccessToken *token = [FBSDKAccessToken currentAccessToken];
NSInteger expiration = token.expirationDate.timeIntervalSince1970;
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete
userData:@{
@"opened" : @"true",
@"access_token" : [FBSDKAccessToken currentAccessToken].tokenString,
@"expiration_timestamp" : [@(expiration) stringValue],
@"user_id" : [FBSDKAccessToken currentAccessToken].userID,
@"permissions" : [token.permissions allObjects],
}
requestId:0];
return;
} else {
[FBUnityUtility sendErrorToUnity:FBUnityMessageName_OnInitComplete errorMessage:@"Unknown login error" requestId:0];
}
这篇关于facebook unity sdk 7.0.2-重新打开应用程序时FB.IsLoggedIn返回false,但仍应登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!