xamarin how to open facebook and twitter app from

2019-06-24 22:35发布

问题:

i'm developing a ios app with xamarin, in c#. I have a "contact" UIViewController, with some buttons, including Facebook and Twitter.

I need to open Facebook and Twitter App from my app, that points to a specific Facebook Page and Twitter profile.

Which is the best way to do this?

Thanks in advance...

回答1:

Try this :

Device.OpenUri(new Uri("fb://page/page_id"));
Device.OpenUri(new Uri("twitter://user?user_id=userid"));

For page_id right click on page and select view source page and find the page_id for facebook and same as for twitter find the userid



回答2:

In addition to accepted answer, following are my finding to open links in external applications.
To open link in browser:

Device.OpenUri(new Uri("http://example.in/index.html"));

To open group in facebook:

Device.OpenUri(new Uri("fb://group/groupname"));

To open page in facebook:

Device.OpenUri(new Uri("fb://page/page_id"));

To open user in instagram:

Device.OpenUri(new Uri("instagram://user?username=yourUserName"));

To open user in twitter:

Device.OpenUri(new Uri("twitter://userName?user_id=userId"));

To open mail app:

Device.OpenUri(new Uri("mailto:example@gmail.com"));