解决方法
获取AppDeeplink非常有用,例如在ShareStatusTask和ShareLinkTask中.
但是,您可以使用一些非平凡的代码从应用程序清单文件中获取真正的AppID.这是我做的:
首先在资源的某处保存Windows Phone应用程序深层链接的字符串,这很简单:
但是,您可以使用一些非平凡的代码从应用程序清单文件中获取真正的AppID.这是我做的:
首先在资源的某处保存Windows Phone应用程序深层链接的字符串,这很简单:
“http://windowsphone.com/s?appId={0}”
然后你必须通过打开App Manifest文件并找到正确的标签来找到真正的AppId,我在MarketplaceHelper中使用此代码来执行此操作:
static MarketplaceHelper() { try { // load product details from WMAppManifest.xml XElement app = XElement.Load("WMAppManifest.xml").Descendants("App").Single(); Title = GetValue(app,"Title"); Version = new Version(GetValue(app,"Version")); Author = GetValue(app,"Author"); Publisher = GetValue(app,"Publisher"); Description = GetValue(app,"Description"); // remove the surrounding braces string productID = GetValue(app,"ProductID"); ProductID = Regex.Match(productID,"(?<={).*(?=})").Value; } catch (Exception e) { // should not happen,every application has this field and should containt the ProductID and Version } } private static string GetValue(XElement app,string attrName) { XAttribute at = app.Attribute(attrName); return at != null ? at.Value : null; }
如果Manifest在那里并且格式正确,它应该是,否则应用程序将无法工作,您可以通过这种方式获得您想要的任何数据.
现在你可以像这样构建deeplink:
string deeplink = string.Format(AppResources.DeepLinkFormat,MarketplaceHelper.ProductID);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。