Skip to content

Commit 5622848

Browse files
Fixed bug where the user is not logged in on subsequent sessions
Summary: Bug reported in GitHub: #695 "FB SDK doesn't keep user logged in on subsequent sessions". It's only happening in the last release of the SDK and on iOS according to user and partner reports. This diff fixes this issue. According to the instructions in the iOS SDK (https://github.com/facebook/facebook-ios-sdk/blob/41044df838ef3fefe600fb96b6560dc8a2b2a18a/FBSDKCoreKit/FBSDKCoreKit/ApplicationDelegate.swift#L55-L56), "Do not use the method initializeSDK if you are using the SDK within the context of the 'UIApplication' lifecycle", which is the case of the Unity SDK, "Instead use 'application(_:didFinishLaunchingWithOptions:)'" Basically, the didFinishLaunchingWithOptions method is called after state restoration has occurred (for example, when the app is launched again after it is suspended or in the background). It is needed to restore the user information, such as the access token. Reviewed By: GMc14 Differential Revision: D48560401 fbshipit-source-id: 6a6269ad8392db164638e24b04a666c71bfe5c7f
1 parent b8db43b commit 5622848

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

UnitySDK/Assets/FacebookSDK/SDK/Editor/iOS/FBUnityInterface.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ + (void)load
6262

6363
- (void)didFinishLaunching:(NSNotification *)notification
6464
{
65-
65+
[[FBSDKApplicationDelegate sharedInstance] application:[UIApplication sharedApplication]
66+
didFinishLaunchingWithOptions:notification.userInfo];
6667
}
6768

6869
- (void)didBecomeActive:(NSNotification *)notification
@@ -394,9 +395,6 @@ void IOSFBSendViewHierarchy(const char *_tree )
394395

395396
void IOSFBInit(const char *_appId, bool _frictionlessRequests, const char *_urlSuffix, const char *_userAgentSuffix)
396397
{
397-
// Initialize SDK first
398-
[[FBSDKApplicationDelegate sharedInstance] initializeSDK];
399-
400398
// Set the user agent before calling init to ensure that calls made during
401399
// init use the user agent suffix.
402400
[FBSDKSettings.sharedSettings setUserAgentSuffix:[FBUnityUtility stringFromCString:_userAgentSuffix]];

0 commit comments

Comments
 (0)