DeepLinkBaseResultObserver
note
When the native layer receives DeepLink data, it saves it to the SDK. The game needs to call the Fetch
function to obtain this data. After calling Fetch
, the DeepLink data is cleared.
note
It is strongly recommended to perform registration in the startup function of the game application.
Function definition
C++ event handling (above V1.15)
//configure callback
void SetDeepLinkObserver(FINTLDeepLinkEvent& callback);
//get callback
FINTLDeepLinkEvent& GetDeepLinkObserver();
Unreal Engine event handling
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "INTLSDKObserver")
void OnDeepLinkResult(FINTLBaseResult ret);
virtual void OnDeepLinkResult_Implementation(FINTLBaseResult ret) {};
Code sample
// DeepLink callback
void OnDeepLinkResult_Implementation(FINTLBaseResult ret)
{
AppendResultText("DeepLinkResult:");
if (ret.RetCode == ErrorCode::SUCCESS) {
UE_LOG(LogTemp, Warning, TEXT("[OnDeepLinkResultNotify] Sucessed MethodId:%d"), ret.MethodId);
}
else {
UE_LOG(LogTemp, Warning, TEXT("[OnDeepLinkResultNotify] Failed MethodId:%d"), ret.MethodId);
}
// When data is available, call Fetch to get it
FString url = UINTLSDKAPI::Fetch();
FString jsonurl = "";
TMap<FString, FString> Params;
TSharedPtr<FJsonObject> json;
TSharedRef<TJsonReader<TCHAR>> jsonReader = TJsonReaderFactory<TCHAR>::Create(url);
if (FJsonSerializer::Deserialize(jsonReader, json))
{
jsonurl = json->GetStringField("url");
TSharedPtr<FJsonObject> JsonMap = json->GetObjectField("params");
for (auto KeyValueIt = JsonMap->Values.CreateConstIterator(); KeyValueIt; ++KeyValueIt)
{
FString Value = JsonMap->GetStringField(KeyValueIt.Key());
Params.Add(KeyValueIt.Key(), Value);
}
}
if (jsonurl != "")
{
AppendResultText("url:");
AppendResultText(jsonurl);
AppendResultText("Params:");
for (TMap<FString, FString>::TConstIterator iter(Params); iter; ++iter)
{
AppendResultText(FString::Printf(TEXT(" %s : %s"), *iter->Key, *iter->Value));
}
}
}