deep-linking - Branch.io initSession 返回空的 BranchUniversalObject JSON 和 BranchLinkProperties JSON
问题描述
我正在尝试使用 Unity Branch SDK 向我现有的应用程序添加共享功能。
我使用以下代码创建了短 URL。
BranchUniversalObject universalObject = new BranchUniversalObject();
BranchLinkProperties linkProperties = new BranchLinkProperties();
string deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
universalObject.canonicalIdentifier = $"xLeague/{deviceUniqueIdentifier}";
universalObject.canonicalUrl = "http://xleague.games/";
universalObject.title = MetaDataManager.Title;
universalObject.contentDescription = MetaDataManager.Description;
universalObject.imageUrl = MetaDataManager.Image;
linkProperties.controlParams.Add("$desktop_url", "http://xleague.games/xleague-solitaire-share/");
linkProperties.controlParams.Add("$android_url", "http://xleague.games/android");
linkProperties.controlParams.Add("$ios_url", "https://apps.apple.com/us/app/xleague-solitaire/id1480117114");
linkProperties.controlParams.Add("$ipad_url", "https://apps.apple.com/us/app/xleague-solitaire/id1480117114");
linkProperties.controlParams.Add("$match_duration", "2000");
linkProperties.controlParams.Add("$og_title", MetaDataManager.Title);
linkProperties.controlParams.Add("$og_description", MetaDataManager.Description);
linkProperties.controlParams.Add("$og_image_url", MetaDataManager.Image);
linkProperties.controlParams.Add("$deviceID", deviceUniqueIdentifier);
Branch.getShortURL(universalObject, linkProperties, (param, error) =>
{
if (error != null)
{
Debug.LogError("Branch.getShortURL failed: " + error);
}
else if (param != null)
{
callback(param);
}
});
我可以从 Unity Branch 获得以下短 URL。
https://xleague.app.link/r7DxT2wkZ5
https://xleague.app.link/4WPwY7jm05
https://xleague.app.link/LFfAOZuo05
https://xleague.app.link/hVR3fr0n05
我使用以下代码检索 BranchUniversalObject 和 BranchLinkProperties。
void Start()
{
Branch.initSession(CallbackWithBranchUniversalObject);
}
void CallbackWithBranchUniversalObject(BranchUniversalObject buo, BranchLinkProperties linkProps, string error)
{
if (error != null)
Debug.Log($"Error : {error}");
else
{
Debug.Log(buo.ToJsonString());
Debug.Log(linkProps.ToJsonString());
if (linkProps.controlParams.ContainsKey("$deviceID"))
{
string senderDeviceID = linkProps.controlParams["$deviceID"];
...
}
}
}
如果我在 iPhone 或 Android 上单击共享链接,它会将我重定向到 Appstore 或 Google Play 商店。我可以在 Appstore 和 Google Play Store 上安装该应用程序。但是当我打开应用程序时,initSession 返回空的 BranchUniversalObject JSON 和 BranchLinkProperties JSON。
BranchUniversalObject JSON
{
"$canonical_identifier": "",
"$canonical_url": "",
"$og_title": "",
"$og_description": "",
"$og_image_url": "",
"$publicly_indexable": "0",
"$locally_indexable": "0",
"$exp_date": "69425078400000",
"$keywords": [],
"metadata": "{}"
}
分支链接属性 JSON
{
"~tags": [],
"~feature": "",
"~alias": "",
"~channel": "",
"~stage": "",
"~duration": "0",
"control_params": {}
}
让我更困惑的是,initSession 有时会按预期返回正确的 BranchUniversalObject JSON 和 BranchLinkProperties JSON。我猜我创建的 Branch Short URL 仅适用于第一次点击。如果您能帮助我,我将不胜感激。
解决方案
推荐阅读
- java - 如何在对象中居中文本并使其随对象移动
- jsf-2 - FacesContext.isPartialRequest()
- java - Cannot run deprecated java applet on MacOS High Sierra
- c++ - SFML 窗口没有响应
- c# - Fastest way to update a DataGridView connected to asynchronously and constantly updating DataTable
- angularjs - 从 Firebase 中检索对象 (AngularFire)
- flutter - Refresh indicator without scrollview
- python - How to store elements from my regression in a new dataframe?
- ios - How to convert Date to String in Swift
- actions-on-google - 如何构建一个从网站读取状态的 Google Voice 应用程序?