ShareKit iOS - different content for different platforms

匿名 (未验证) 提交于 2019-12-03 09:10:12

问题:

I am trying to use ShareKit to share via email an HTML string and share on Facebook a regular stream containing an image and some text.

The sample project just shows how to share the same info for every platform(Twitter, Facebook, email) but I want to be able to share different content according to the platform.

SHKItem *item = [SHKItem image:image title: @"title"]; item.text = @"share text"; SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];  

any ideas?

回答1:

I was looking for something similar and found it in ShareKit's documentation: http://www.getsharekit.com/docs/

What you are looking for (I believe) is sharing to a specific service provider, and not using that action sheet interface. That's what I've done to create different content for different platforms.

Code:

#import "SHKFacebook.h" #import "SHKTwitter.h"  ...  - (IBAction)shareOnFacebook {     // Create an image item     SHKItem *item = [SHKItem image:[UIImage imageNamed:@"myImage.png"] title:@"A Girraffe!"];      // Share the item on Facebook     [SHKFacebook shareItem:item];      return; }  - (IBAction)shareOnTwitter {     // Create a text item     NSString *someText = @"This is a blurb of text I highlighted from a document.";     SHKItem *item = [SHKItem text:someText];      // Share the item on Twitter     [SHKTwitter shareItem:item];      return; } 

Hope this helps! Oded.



回答2:

My own experience: I succeeded in only sharing URLs on Twitter while sharing both URLs and images on Facebook.

What I did: I rewrote some of SHKItem's instance methods, such as:

//original SHKItem *item = [SHKItem image:image title: @"title"]; //new version SHKItem *item = [SHKItem image:image url:aURL title: @"title"]; 

and other related methods. In this way whenever I created a SHKItem instance, I would be able to pass both URLs and images to the following classes that are going to handle the sharing issues.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!