JaykeBird
JaykeBird

Reputation: 382

How to share URL using Xamarin iOS

I'm developing an app for my local newspaper. When you press the "Share" button, I want the standard iOS share interface to appear allowing users to share the URL of an article with Facebook, Twitter, etc. I'm trying to use the UIActivityViewController, and while it appears, it's not giving me all of the options.

Here's the code I use:

NSObject[] activitiesItems = { 
                                new NSString(post.Title),
                                new NSUrl(post.URL)
                             };

var activityController = new UIActivityViewController(activitiesItems, null);
PresentViewController(activityController, true, null);

When the UI opens, this is all I see (no Twitter or Facebook): sharing options in my app

This is in comparison to what I see when I share a page from Safari, which has the Facebook and Twitter options, along with a variety of others: sharing options in Safari

What do I have to change in my code to allow more of these options to appear?

Upvotes: 3

Views: 1209

Answers (2)

SushiHangover
SushiHangover

Reputation: 74094

1) Your code is fine

2) On your iOS Simulator go to the Setting and login to Twitter and/or FaceBook accounts and retest your app.

iOS Simulator Setting (botton off screen):

enter image description here

Here is my Simulator view with me logged into Twitter but not Facebook using the same code you posted:

enter image description here

3) Safari is a using a custom ViewController to display what you are seeing... If you actually try to share a link via that Twitter button you will be force to login..

4) Use an actual device for complete testing of all the possible sharing applications installed.

Upvotes: 2

Keith Rome
Keith Rome

Reputation: 3228

Those options are only supposed to show when you are logged in to an account in the Settings app for FB and Twitter. They are hidden if not.

However that doesn't really explain why they show up in Safari.

Perhaps including the NSString for post.Title in the items array is causing it to exclude some sharing options.

Upvotes: 1

Related Questions