Callback for DeepLink (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
// Set DeepLink callback to notify the engine layer if data arrives. After receiving the callback, manually call the Fetch function to retrieve data.
public static void SetDeepLinkObserver(OnINTLResultHandler<INTLBaseResult> callback);
// Remove DeepLink callback
public static void RemoveDeepLinkObserver(OnINTLResultHandler<INTLBaseResult> callback);
Code example
// Add callback
public void SetDeepLinkObserver()
{
INTLAPI.SetDeepLinkObserver(OnDeepLinkResult);
}
// Remove callback
public void RemoveDeepLinkObserver()
{
INTLAPI.RemoveDeepLinkObserver(OnDeepLinkResult);
}
// Handle callback data
private void OnDeepLinkResult(INTLBaseResult result)
{
m_sample.ShowLogInNewLine("OnDeepLinkResult");
// Data has arrived, call Fetch to retrieve
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]);
}
}
}