Please Select Your Location
Australia
Österreich
België
Canada
Canada - Français
中国
Česká republika
Denmark
Deutschland
France
HongKong
Iceland
Ireland
Italia
日本
Korea
Latvija
Lietuva
Lëtzebuerg
Malta
المملكة العربية السعودية (Arabic)
Nederland
New Zealand
Norge
Polska
Portugal
Russia
Saudi Arabia
Southeast Asia
España
Suisse
Suomi
Sverige
台灣
Ukraine
United Kingdom
United States
Please Select Your Location
België
Česká republika
Denmark
Iceland
Ireland
Italia
Latvija
Lietuva
Lëtzebuerg
Malta
Nederland
Norge
Polska
Portugal
España
Suisse
Suomi
Sverige

Unreal

ViveportDeeplinkDemo.h

#include "Components/ActorComponent.h"
#include "ViveportApi.h"
#include "ViveportDeeplink.h"
#include "ViveportDeeplinkDemo.generated.h"
 
 
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class VIVEPORTSDK_API UViveportDeeplinkDemo : public UActorComponent
{
    GENERATED_BODY()
 
public:
    // Sets default values for this component's properties
    UViveportDeeplinkDemo();
 
    /** The VIVEPORT ID for auth verify */
    FString VIVEPORT_ID = "bd67b286-aafc-449d-8896-bb7e9b351876";
 
    /** Public key for auth verify */
    FString VIVEPORT_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDFypCg0OHfBC+VZLSWPbNSgDo9qg/yQORDwGy1rKIboMj3IXn4Zy6h6bgn8kiMY7VI0lPwIj9lijT3ZxkzuTsI5GsK//Y1bqeTol4OUFR+47gj+TUuekAS2WMtglKox+/7mO6CA1gV+jZrAKo6YSVmPd+oFsgisRcqEgNh5MIURQIDAQAB";
 
    FString TARGET_APP_VIVEPORT_ID = "bbbc73fc-b018-42ce-a049-439ab378dbc6";
 
    FString LAUNCH_DATA = "lauch_data";
 
protected:
    // Called when the game starts
    virtual void BeginPlay() override;
public:
    // callback interface
    class MyViveportDeeplinkStatus : public ViveportApiStatus
    {
    protected:
        UViveportDeeplinkDemo* mDemo;
    public:
        void SetDemoPtr(UViveportDeeplinkDemo* p) { mDemo = p; }
    };
 
    class MyViveportDeeplinkStatus2 : public ViveportApiStatus2
    {
    protected:
        UViveportDeeplinkDemo* mDemo;
    public:
        void SetDemoPtr(UViveportDeeplinkDemo* p) { mDemo = p; }
    };
 
 
    class MyInitCallback : public MyViveportDeeplinkStatus
    {
    public:
        void OnSuccess(
        ) override;
        void OnFailure(int errorCode
        ) override;
    };
 
    MyInitCallback myInitCallback;
 
    class MyDeeplinkIsReadyCallback : public MyViveportDeeplinkStatus
    {
    public:
        void OnSuccess(
        ) override;
        void OnFailure(int errorCode
        ) override;
    };
 
    MyDeeplinkIsReadyCallback myDeeplinkIsReadyCallback;
 
    class MyDeeplinkCallback : public MyViveportDeeplinkStatus2
    {
    public:
        void OnSuccess(
            const FString& result
        ) override;
        void OnFailure(
            int errorCode,
            const FString& errorMessage
        ) override;
    };
 
    MyDeeplinkCallback myDeeplinkCallback;
 
    MyDeeplinkIsReadyCallback* GetDeeplinkIsReadyCallback() { return &myDeeplinkIsReadyCallback; }
    MyDeeplinkCallback* GetDeeplinkCallback() { return &myDeeplinkCallback; }
};

ViveportDeeplinkDemo.cpp

#include "ViveportSDKPrivatePCH.h"
#include "ViveportDeeplinkDemo.h"
 
// Sets default values for this component's properties
UViveportDeeplinkDemo::UViveportDeeplinkDemo()
{
    // Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
    // off to improve performance if you don't need them.
    PrimaryComponentTick.bCanEverTick = false;
}
 
// Called when the game starts
void UViveportDeeplinkDemo::BeginPlay()
{
    Super::BeginPlay();
 
    myInitCallback.SetDemoPtr(this);
    myDeeplinkIsReadyCallback.SetDemoPtr(this);
    UViveportApi::Init(&myInitCallback, VIVEPORT_ID);
}
 
/***************************************************************
*                                   MyInitCallback
***************************************************************/
 
void UViveportDeeplinkDemo::MyInitCallback::OnSuccess()
{
    UE_LOG(ViveportSDK, Error, TEXT("[UViveportDeeplinkDemo][MyInitCallback] Init Success"));
    FString fstring("Init success.");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
    UViveportDeeplink::IsReady(mDemo->GetDeeplinkIsReadyCallback());
}
 
void UViveportDeeplinkDemo::MyInitCallback::OnFailure(int errorCode)
{
    UE_LOG(ViveportSDK, Error, TEXT("[UViveportDeeplinkDemo][MyInitCallback] Init failure. Code = %d"), errorCode);
    FString fstring = FString::Printf(TEXT("Init failure. error=%d"), errorCode);
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
}
 
void UViveportDeeplinkDemo::MyDeeplinkIsReadyCallback::OnSuccess()
{
    FString lauchData = TEXT("GetLaunchData : ") + UViveportDeeplink::GetAppLaunchData();
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, lauchData);
 
    FString f1string("Start GoToAppOrGoToStore");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, f1string);
    UViveportDeeplink::GoToAppOrGoToStore(mDemo->GetDeeplinkCallback(), mDemo->TARGET_APP_VIVEPORT_ID, mDemo->VIVEPORT_KEY);
 
    /* Test GoToApp
    FString fstring("Start GoToApp");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
    UViveportDeeplink::GoToApp(mDemo->GetDeeplinkCallback(), mDemo->TARGET_APP_VIVEPORT_ID, mDemo->VIVEPORT_KEY);
    */
 
    /*Test GoToApp with BranchName PROD or BETA
    FString f2string("Start GoToApp");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, f2string);
    UViveportDeeplink::GoToApp(mDemo->GetDeeplinkCallback(), mDemo->TARGET_APP_VIVEPORT_ID, mDemo->VIVEPORT_KEY, TEXT("PROD"));
    */
 
    /*Test GoToStore
    FString f3String("Start GoToStore");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, f3String);
    UViveportDeeplink::GoToStore(mDemo->GetDeeplinkCallback(), mDemo->TARGET_APP_VIVEPORT_ID);
    */
}
 
void UViveportDeeplinkDemo::MyDeeplinkIsReadyCallback::OnFailure(int errorCode)
{
    UE_LOG(ViveportSDK, Error, TEXT("[UViveportDeeplinkDemo][MyDeeplinkIsReadyCallback] DeeplinkIsReady failure. Code = %d"), errorCode);
    FString fstring = FString::Printf(TEXT("DeeplinkIsReady failure. error=%d"), errorCode);
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
}
 
/***************************************************************
*                                   MyDeeplinkCallback
***************************************************************/
 
void UViveportDeeplinkDemo::MyDeeplinkCallback::OnSuccess(const FString& result)
{
    UE_LOG(ViveportSDK, Error, TEXT("[UViveportDeeplinkDemo][MyDeeplinkCallback] DeeplinkCallback Success"));
    FString fstring("Deeplink is Success!!");
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
}
 
void UViveportDeeplinkDemo::MyDeeplinkCallback::OnFailure(int errorCode, const FString& errorMessage)
{
    UE_LOG(ViveportSDK, Error, TEXT("[UViveportDeeplinkDemo][MyDeeplinkCallback] DeeplinkCallback failure. Code = %d"), errorCode);
    FString fstring = FString::Printf(TEXT("DeeplinkCallback failure errorCode = %d errorMessage = %s"), errorCode, *errorMessage);
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::White, fstring);
}