Skip to main content

Callback for DeepLink (DeepLinkBaseResultObserver)

If you are using the Unity engine, please refer to Unity SDK's DeepLinkBaseResultObserver.

note

After the native layer receives DeepLink data, it is stored in the SDK and the game side needs to call Fetch to actively retrieve the data.After calling Fetch, the DeepLink data will be cleared.

note

It is strongly recommended to register at the application startup function.

Function Definition

C++ Event Handling Method (V1.15 and above)

// Configure callback
void SetDeepLinkObserver(FINTLDeepLinkEvent& callback);
// Obtain callback
FINTLDeepLinkEvent& GetDeepLinkObserver();

Unreal Engine Event Handling Method

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);
}

// Data arrives, call Fetch to obtain
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));
}
}
}