[英]How can I open the Facebook App for sharing a link on WP8?
I wonder how to open the official Facebook App for sharing an URI from my C# code on Windows Phone.我想知道如何打开官方 Facebook 应用程序以从 Windows Phone 上的 C# 代码共享 URI。 The common Uri-Scheme like
"fb://"
may open the App but no parameter seems to work.像
"fb://"
这样的常见 Uri-Scheme 可能会打开应用程序,但似乎没有参数起作用。 I have something like this in mind, but it will not work for me:我有这样的想法,但它对我不起作用:
LaunchUriAsync(new Uri("fb://publish/profile/me?text=foo"));
Of course I know that I could use the ShareTask
but that's not what I want.当然我知道我可以使用
ShareTask
但这不是我想要的。 You can take a look at the Spotfy App, it does exactly, what I want to do, when sharing a song.您可以查看 Spotfy 应用程序,在分享歌曲时,它完全符合我的要求。
Thank you for your help and answers!感谢您的帮助和解答!
PS: Same with Twitter by the way... PS:顺便说一下,和推特一样......
I finally solved it!我终于解决了! It took me nearly two days to find the solution and it is not documented anywhere sothat I would like to share my results with you:
我花了将近两天的时间才找到解决方案,并且没有在任何地方记录,因此我想与您分享我的结果:
// Open official Facebook app for sharing
await Windows.System.Launcher.LaunchUriAsync(new Uri("fb:post?text=foo"));
I think this is a very cool feature and reminds users of how it works on other plarforms.我认为这是一个非常酷的功能,并提醒用户它在其他平台上的工作方式。
In conclusion launching other apps from your app via URI schemes is always a great scenario with a nice user experience.总之,通过 URI 方案从您的应用程序启动其他应用程序始终是一个具有良好用户体验的好场景。
Hint : Opening the official Facebook App via URI schemes requires at least version 4.1!提示:通过 URI 方案打开官方 Facebook 应用程序至少需要 4.1 版本!
If you wanna share the link, you can use ShareLinkTask
如果你想分享链接,你可以使用
ShareLinkTask
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "My Title";
shareLinkTask.LinkUri = new Uri("http://fb.me/profile.php", UriKind.Absolute);
shareLinkTask.Message = "Yep. I can share a link on facebook.";
shareLinkTask.Show();
When user calls this method, it will show the sharable social networking apps installed on the phone, so you can share a link on the facebook, twitter & etc (if installed)当用户调用此方法时,它会显示手机上安装的可共享社交网络应用程序,因此您可以在 facebook、twitter 等(如果已安装)上共享链接
If you wanna share the local media file, you can use ShareMediaTask
如果要共享本地媒体文件,可以使用
ShareMediaTask
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.