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
// Set the DeepLink callback, which notifies the game when data reaches the engine layer. When this callback is received, call the `Fetch` function to obtain the data.
public static void SetDeepLinkObserver(OnINTLResultHandler<INTLBaseResult> callback);
// Remove DeepLink callback
public static void RemoveDeepLinkObserver(OnINTLResultHandler<INTLBaseResult> callback);
Code sample
// Add callbacks
public void SetDeepLinkObserver()
{
INTLAPI.SetDeepLinkObserver(OnDeepLinkResult);
}
// Remove callbacks
public void RemoveDeepLinkObserver()
{
INTLAPI.RemoveDeepLinkObserver(OnDeepLinkResult);
}
// Process the Deeplink callback
private void OnDeepLinkResult(INTLBaseResult result)
{
m_sample.ShowLogInNewLine("OnDeepLinkResult");
// When data is available, call Fetch to get it
string deeplinkret = ToolApiCall.Instance.Fetch();
object jsonresult = Json.Deserialize(deeplinkret);
var dict = jsonresult as Dictionary<string, object>;
string url = "";
if (dict.ContainsKey("url"))
{
url = dict["url"] as string;
}
if (result.RetCode != 0)
{
m_sample.ShowLogInNewLine("failed to parse params.");
return;
}
Dictionary<string, string> parameret = new Dictionary<string, string>();
if (dict.ContainsKey("params"))
{
object par = dict["params"];
Dictionary<string, object> paramer = par as Dictionary<string, object>;
foreach (string key in paramer.Keys)
{
parameret.Add(key, paramer[key] as string);
}
}
if (url != "")
{
ShowLogInNewLine("url:");
ShowLogInNewLine(url);
ShowLogInNewLine("params:");
foreach (string key in parameret.Keys)
{
ShowLogInNewLine(key + ":" + parameret[key]);
}
}
}