IOS OnlineSubsystemFacebook module is not working?

Hello,
I am trying to integrate Facebook in my IOS game but before doing everything manually by myself,i decided to use what’s already there in unreal engine source code in OnlineSubsystemFacebook module.

Here is how my code looks like…

In build.cs

if (Target.Platform == UnrealTargetPlatform.IOS)
        {
            PublicDependencyModuleNames.AddRange(
                new string[]
                {
                    "OnlineSubsystem",
                    "OnlineSubsystemFacebook"                       
                }
            );

            PublicIncludePaths.Add("Runtime/Online/OnlineSubsystemFacebook/Private/IOS");
            PublicIncludePaths.Add("Runtime/Online/OnlineSubsystem/Public/Interfaces");

}

FacebookLoginComponent.h

#pragma once

#include "FacebookLoginComponent.generated.h"

UCLASS()
class UFacebookLoginComponent : public UActorComponent
{
    GENERATED_BODY()
    
public:
    void OnRegister() override;
    void OnUnregister() override;

    UFUNCTION(BlueprintCallable, meta = (Keywords = "facebook"), Category = "Facebook")
    static void FacebookLogIn();
 
}

FacebookLoginComponent.cpp

#include "FacebookPluginPrivatePCH.h"
#include "FacebookLoginComponent.h"

#if PLATFORM_IOS
#include "OnlineIdentityFacebook.h"
#include "OnlineIdentityInterface.h"
#endif

void UFacebookLoginComponent::OnRegister()
{
    Super::OnRegister();
    
    // init here
}

void UFacebookLoginComponent::OnUnregister()
{
    Super::OnUnregister();
}

void UFacebookLoginComponent::FacebookLogin()
{

#if PLATFORM_IOS

    FOnlineIdentityFacebook SetUpLogin;
    FOnlineAccountCredentials AccountCredentials;
    AccountCredentials.Type = "Facebook";
    AccountCredentials.Id = "email";
    AccountCredentials.Token = "password";
    
    SetUpLogin.Login(1,AccountCredentials);

#endif

}

I am calling the FacebookLogin() when a button is clicked in game.
It shows the Facebook login screen and after completing the login process,i am getting a blank white screen.
Normally,it should switch back to the game,but,it is not doing so.Here’s an image of the screen after login.

When i click “Done” nothing happens and when,i take a look in the log,it shows that user has cancelled login message.
And throws an error as shown in the image below.

I have added the necessary settings for Facebook integration in my plist as mentioned in the getting started guide of Facebook. I am using ios 9.
Am i doing something wrong? Please help!
Thank you!

I am not sure,what i was doing wrong,but,after creating another project and trying it again,it worked.Maybe,my project got corrupted as i was facing some other issues too with it.

Thank you!

Hi Superflare,

There are a couple of things here that I’d like to go over. The use of OSS Facebook in the explicit manner is not recommended.

Instead, I suggest that you use the OSS interfaces to manage Online Subsystem

const FName FacebookOSSName("Facebook");

IOnlineIdentityPtr OnlineIdentity = Online::GetIdentityInterface(FacebookOSSName);
if (OnlineIdentity.IsValid())
{
	OnlineIdentity->AddOnLoginCompleteDelegate_Handle(0, OnLoginCompleteDelegate);
	OnlineIdentity->AddOnLogoutCompleteDelegate_Handle(0, OnLogoutCompleteDelegate);

	OnlineIdentity->Login(0, AccountCredentials);
}

I would also drop the PublicIncludePaths that were added, as this completely bypasses any reason the files are private.

Any activities you wish to continue with after login should be managed through your OnLoginCompleteDelegate delegate.

Hope this helps.
/

Thank you,!

I didn’t know about OSS interface,i will look into it now.
I have actually went the manual way for integrating Facebook as i think that the OSS Facebook module is still under development and i am trying to stay away from editing anything in UE4 source code.

It is working fine so far but the only thing that worries me is this line in my code…

FIOSCoreDelegates::OnOpenURL.AddStatic(&FacebookOpenURLHandler);

I mean,i am not sure how to remove it when it is unregistered.
Usually for the methods added with AddUObject,i use this…

SomeDelegate.RemoveAll(this);

I am not sure,how to do it for AddStatic.