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!