Skip to content

Commit

Permalink
fix: updated apple platform related source code files
Browse files Browse the repository at this point in the history
  • Loading branch information
YermekG committed Jan 10, 2024
1 parent 6c598b6 commit bbed0b3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
Binary file modified Content/PackagedResources/index.uasset
Binary file not shown.
36 changes: 35 additions & 1 deletion Source/Immutable/Private/Immutable/IOS/ImmutableIOS.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "ImmutableIOS.h"
#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Engine/GameEngine.h"

API_AVAILABLE(ios(12.0))
ASWebAuthenticationSession *_authSession;
Expand All @@ -20,6 +22,34 @@ ASWebAuthenticationSession *_authSession;
return staticImmutableIOS;
}

+ (UImmutablePassport*) getPassport {
UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);

if (!GameEngine) {
return nil;
}

UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL;

if (!World) {
return nil;
}

auto ImmutableSubsystem = World->GetGameInstance()->GetSubsystem<UImmutableSubsystem>();

if (!ImmutableSubsystem) {
return nil;
}

auto Passport = ImmutableSubsystem->GetPassport();

if (!Passport.IsValid()) {
return nil;
}

return Passport.Get();
}

- (void)launchUrl:(const char *)url {
NSURL *URL = [NSURL URLWithString:[[NSString alloc] initWithUTF8String:url]];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
Expand All @@ -31,7 +61,11 @@ ASWebAuthenticationSession *_authSession;
NSError *_Nullable error) {
_authSession = nil;
if (callbackURL) {
UImmutablePassport::HandleDeepLink(callbackURL.absoluteString);
UImmutablePassport* passport = [ImmutableIOS getPassport];

if (passport) {
passport->HandleDeepLink(callbackURL.absoluteString);
}
} else {
return;
}
Expand Down
12 changes: 4 additions & 8 deletions Source/Immutable/Private/Immutable/ImmutablePassport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ void UImmutablePassport::OnLogoutResponse(FImtblJSResponse Response)
}
#elif PLATFORM_ANDROID
LaunchAndroidUrl(Url);
#elif PLATFORM_IOS || PLATFORM_MAC
[[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI(*Url)];
#endif
}
bIsLoggedIn = false;
Expand Down Expand Up @@ -519,14 +521,6 @@ void UImmutablePassport::OnGetPKCEAuthUrlResponse(FImtblJSResponse Response)
OnPKCEDismissed = FImtblPassportOnPKCEDismissedDelegate::CreateUObject(this, &UImmutablePassport::HandleOnLoginPKCEDismissed);
LoginPKCEUrl = Msg;
LaunchAndroidUrl(Msg);
// if (Env)
// {
// jstring jurl = Env->NewStringUTF(TCHAR_TO_UTF8(*Msg));
// jclass jimmutableAndroidClass = FAndroidApplication::FindJavaClass("com/immutable/unreal/ImmutableAndroid");
// static jmethodID jlaunchUrl = FJavaWrapper::FindStaticMethod(Env, jimmutableAndroidClass, "launchUrl", "(Landroid/app/Activity;Ljava/lang/String;)V", false);
//
// CallJniStaticVoidMethod(Env, jimmutableAndroidClass, jlaunchUrl, FJavaWrapper::GameActivityThis, jurl);
// }
#elif PLATFORM_IOS
[[ImmutableIOS instance] launchUrl:TCHAR_TO_ANSI(*Msg)];
#elif PLATFORM_MAC
Expand Down Expand Up @@ -889,7 +883,9 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink)
{
CompleteLoginPKCEFlow(DeepLink);
}
#if PLATFORM_ANDROID
LoginPKCEUrl.Empty();
#endif
}

void UImmutablePassport::CompleteLoginPKCEFlow(FString Url)
Expand Down
36 changes: 35 additions & 1 deletion Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "ImmutableMac.h"
#include "Immutable/ImmutablePassport.h"
#include "Immutable/ImmutableSubsystem.h"
#include "Engine/GameEngine.h"

ASWebAuthenticationSession *_authSession;

Expand All @@ -19,6 +21,34 @@ ASWebAuthenticationSession *_authSession;
return staticImmutableMac;
}

+ (UImmutablePassport*) getPassport {
UGameEngine* GameEngine = Cast<UGameEngine>(GEngine);

if (!GameEngine) {
return nil;
}

UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL;

if (!World) {
return nil;
}

auto ImmutableSubsystem = World->GetGameInstance()->GetSubsystem<UImmutableSubsystem>();

if (!ImmutableSubsystem) {
return nil;
}

auto Passport = ImmutableSubsystem->GetPassport();

if (!Passport.IsValid()) {
return nil;
}

return Passport.Get();
}

- (void)launchUrl:(const char *)url forRedirectUri:(const char *)redirectUri {
if (@available(macOS 10.15, *)) {
NSURL *URL =
Expand All @@ -40,7 +70,11 @@ ASWebAuthenticationSession *_authSession;
_authSession = nil;

if (callbackURL) {
UImmutablePassport::HandleDeepLink(callbackURL.absoluteString);
UImmutablePassport* passport = [ImmutableMac getPassport];

if (passport) {
passport->HandleDeepLink(callbackURL.absoluteString);
}
} else {
return;
}
Expand Down

0 comments on commit bbed0b3

Please sign in to comment.