diff --git a/Content/PackagedResources/index.uasset b/Content/PackagedResources/index.uasset index 21de0eb..ec82e34 100644 Binary files a/Content/PackagedResources/index.uasset and b/Content/PackagedResources/index.uasset differ diff --git a/Source/Immutable/Private/Immutable/IOS/ImmutableIOS.cpp b/Source/Immutable/Private/Immutable/IOS/ImmutableIOS.cpp index 6043284..85fdfb8 100644 --- a/Source/Immutable/Private/Immutable/IOS/ImmutableIOS.cpp +++ b/Source/Immutable/Private/Immutable/IOS/ImmutableIOS.cpp @@ -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; @@ -20,6 +22,34 @@ ASWebAuthenticationSession *_authSession; return staticImmutableIOS; } ++ (UImmutablePassport*) getPassport { + UGameEngine* GameEngine = Cast(GEngine); + + if (!GameEngine) { + return nil; + } + + UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL; + + if (!World) { + return nil; + } + + auto ImmutableSubsystem = World->GetGameInstance()->GetSubsystem(); + + 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]; @@ -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; } diff --git a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp index 6a55607..288562b 100644 --- a/Source/Immutable/Private/Immutable/ImmutablePassport.cpp +++ b/Source/Immutable/Private/Immutable/ImmutablePassport.cpp @@ -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; @@ -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 @@ -889,7 +883,9 @@ void UImmutablePassport::OnDeepLinkActivated(FString DeepLink) { CompleteLoginPKCEFlow(DeepLink); } +#if PLATFORM_ANDROID LoginPKCEUrl.Empty(); +#endif } void UImmutablePassport::CompleteLoginPKCEFlow(FString Url) diff --git a/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp b/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp index 7c7efa0..1eebcfe 100644 --- a/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp +++ b/Source/Immutable/Private/Immutable/Mac/ImmutableMac.cpp @@ -1,5 +1,7 @@ #include "ImmutableMac.h" #include "Immutable/ImmutablePassport.h" +#include "Immutable/ImmutableSubsystem.h" +#include "Engine/GameEngine.h" ASWebAuthenticationSession *_authSession; @@ -19,6 +21,34 @@ ASWebAuthenticationSession *_authSession; return staticImmutableMac; } ++ (UImmutablePassport*) getPassport { + UGameEngine* GameEngine = Cast(GEngine); + + if (!GameEngine) { + return nil; + } + + UWorld* World = GameEngine ? GameEngine->GetGameWorld() : NULL; + + if (!World) { + return nil; + } + + auto ImmutableSubsystem = World->GetGameInstance()->GetSubsystem(); + + 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 = @@ -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; }