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.
This seems like a bug.
I'm on Unity 5.1.1p4 and building for Android. I haven't tried iOS yet.
Reproduction steps:
Expected behavior:
FB.IsLoggedIn should be true if you were previously logged in. This is how it worked before.
In FBUnityInterface.mm
:
Add to - (id)init
:
[[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:NULL];
Replace in - (void)configureAppId
:
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete userData:@{} requestId:0];
with:
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];
}