Follow

Sharing

Pugpig supports sharing a page. The template application will automatically configure the “action” toolbar button to provide an optional sharing menu.

The shared content usually includes a title and an link to the article. However, you can configure the shared content to include a thumbnail image, a summary or even some article text.

If you want to share an external link for the article you must add a bookmark link to your ATOM feed:

<link rel="bookmark" type=“text/html” href="http://the.com/mypage/web.html"/>

Please note the target page needs to have Open Graph tags set up if you want to share with FaceBook.

Configuring what gets shared

iOS shares using UIActivityViewController, and we provide helpers for building appropriate activities via our KGActivityItemsBuilder interface.

KGActivityItemsBuilder *builder = [[KGActivityItemsBuilder alloc]
initWithPageControl:self.pageControl];
// snapshot attachment behaviour (NO by default) builder.attachSnapshot = YES; // link attachment behaviour (YES by default) builder.attachURL = YES; // default share message. // can contain %%title%% or %%subject%% builder.bodyFormat = @"I'm reading %%title%%"; // change the message for email [builder setBodyFormat:@"I've shared '%%title%%' with you!"
forActivityType:UIActivityTypeMail]; // create a sharing controller UIActivityViewController *avc = [[UIActivityViewController alloc]
initWithActivityItems:[builder activityItems] applicationActivities:nil];

// optionally exclude type you don't what to share avc.excludedActivityTypes = @[UIActivityTypePrint,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
...

// present activity view controller as normal.

Email sharing will convert the HTML on the shared page into plain text. 

Android shares using our ShareManager helper. The individual providers allow different levels of customisation, please check the provider class definitions for more details. Where format strings can be set, they can generally contain placeholders for title, summary, content or url.

// set up providers we want to customise
EmailSharing email = new EmailSharing(pageControl);
FacebookSharing facebook = new FacebookSharing(pageControl);
TwitterSharing twitter = new TwitterSharing(pageControl);
// example format override:
twitter.setTweetFormat("I'm reading %title% (%url%)");

// generic sharing is anything that will respond to an ACTION_SEND intent
GenericSharing generic = new GenericSharing(pageControl);

ShareManager sharing = new ShareManager("Share via");
// change snapshot attachment behavior (true by default)
sharing.setAttachSnapshot(false);
sharing.addSharingService(email);
sharing.addSharingService(facebook);
sharing.addSharingService(twitter);
sharing.addSharingService(generic);
sharing.share();
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk