unity3d 分享文字,图片,链接,文件到Facebook, twitter, delicious, tumblr, google reader
2013-02-26 14:20
579 查看
ShareKit is incredibly easy to add to any existing project. Follow the steps below and you can be up and running in under 15 minutes.
Download
ShareKit
Version 0.2.1 - Download includes ShareKit and an example project.
![](http://www.getsharekit.com/i/install/drag.png)
Open both the example project (that you downloaded in step 1 above) and your app's project in XCode.
Drag the ShareKit Group from the example project into your project's Groups & Files.
Make sure the "Copy items into destination group's folder (if needed)" checkbox is checked.
![](http://www.getsharekit.com/i/install/frameworks.png)
Expand the 'Frameworks' group in your project's file list. Make sure you have the following frameworks:
SystemConfiguration.framework
Security.framework
MessageUI.framework
If you are missing any frameworks, right click the 'Frameworks' group and select Add -> Existing Frameworks. Select the framework you are missing and add it to your project.
If you aren't already, you'll want to make sure your base SDK is at least iOS 4. You can still support older versions (back to 3.*) by setting your deployment target.
This is an easy process, a good walk-through of this process is detailed here: Developing
iPhone Apps with iOS4, deploying to 3.x devices.
Most of the web services that ShareKit integrates require you to use an API key when connecting. An API key is a unique identifer that tells the service what app is making the request.
You have to sign up for each api key, but they are all free and sign-ups are quick.
Locate and open the file SHKConfig.h, just inside the ShareKit group in your project's file list.
At the top you'll find a list of services that require api keys. Each service has a link next to it. Follow the link for each service to get an api key. Fill in the api key for each corresponding service within
SHKConfig.h.
Note: Follow the comments within the SHKConfig file, they provide additional steps and possible customizations for each service.
In any class where you call ShareKit, you'll need to include the ShareKit header at the top. At the top of your class you'll probably see other imports already. Add ShareKit to list like:
![](http://www.getsharekit.com/i/install/button.png)
This section is subjective and entirely depends on how you design your app. It assumes you know how to create a button that performs an action. If you'd like more guidance, take a look a the example project (included
in the ShareKit download). It has a separate example for sharing links, images, text, and files.
You need to add a way to allow the user to say 'hey, I want to share this!'. It is up to you where to place this button and even what it looks like. If your app has a UIToolbar or UINavigationBar, a common practice
is adding a UIBarButtonItem with theUIBarButtonSystemItemAction system
item style.
This icon has become the standard for sharing amongst iOS apps.
An example may look like:
![](http://www.getsharekit.com/i/install/actionSheet.png)
After you've added a button and set a target action to call when it's pushed, it's finally time to call ShareKit.
A user's entry point into ShareKit is an actionsheet. This actionsheet displays the user's most used services and a more button for additional options.
The actionsheet will only display services that can respond to the item you want to share. So the first step is to create an
object (SHKItem) that describes what you want to share (a url, image, text, or file). With that item, you create an actionsheet and display it to the user.
Here are the 3 steps together. In this example we'll share a URL:
That's it! ShareKit will take over from there and handle everything else. This includes logging the user in to their selected service, allowing them to edit the share
item, displaying activity indicators, and even sharing offline.
Note: How/Where you display the action sheet is up to you. On an iPad you may want to display this as a popover from your share button. For all possible options, take a look at the UIActionSheetdocumentation.
To see examples sharing other types of content (images, text, or files) check out the complete
documentation or example project included in the ShareKit download.
If your app can be used without an internet connection, you should support offline sharing. Luckily, this means only adding one additional line of code.
Most ShareKit services support offline sharing. This means when a user shares something while they are disconnected, ShareKit will store it and wait to send until they are connected again.
You just need to tell ShareKit when to retry these offline items. A good time to do this is when the app is opened. Simply add this line when you want ShareKit to try resending the items:
ShareKit 是iPhone中一键分享文字,图片,链接,文件到Facebook, twitter, delicious, tumblr, google reader等第三方网站的objc库
Step 1: Download
DownloadShareKit
Version 0.2.1 - Download includes ShareKit and an example project.
Step 2: Adding ShareKit to your Project
Copy Files from Example Project
![](http://www.getsharekit.com/i/install/drag.png)
Open both the example project (that you downloaded in step 1 above) and your app's project in XCode.
Drag the ShareKit Group from the example project into your project's Groups & Files.
Make sure the "Copy items into destination group's folder (if needed)" checkbox is checked.
Add Frameworks
![](http://www.getsharekit.com/i/install/frameworks.png)
Expand the 'Frameworks' group in your project's file list. Make sure you have the following frameworks:
SystemConfiguration.framework
Security.framework
MessageUI.framework
If you are missing any frameworks, right click the 'Frameworks' group and select Add -> Existing Frameworks. Select the framework you are missing and add it to your project.
Base SDK and Deployment Targets
If you aren't already, you'll want to make sure your base SDK is at least iOS 4. You can still support older versions (back to 3.*) by setting your deployment target.This is an easy process, a good walk-through of this process is detailed here: Developing
iPhone Apps with iOS4, deploying to 3.x devices.
Step 3: Filling in API Keys
Most of the web services that ShareKit integrates require you to use an API key when connecting. An API key is a unique identifer that tells the service what app is making the request.You have to sign up for each api key, but they are all free and sign-ups are quick.
Locate and open the file SHKConfig.h, just inside the ShareKit group in your project's file list.
At the top you'll find a list of services that require api keys. Each service has a link next to it. Follow the link for each service to get an api key. Fill in the api key for each corresponding service within
SHKConfig.h.
Note: Follow the comments within the SHKConfig file, they provide additional steps and possible customizations for each service.
Step 4: Calling ShareKit
Import the ShareKit Header
In any class where you call ShareKit, you'll need to include the ShareKit header at the top. At the top of your class you'll probably see other imports already. Add ShareKit to list like:#import "SHK.h"
Add a Share Button
![](http://www.getsharekit.com/i/install/button.png)
This section is subjective and entirely depends on how you design your app. It assumes you know how to create a button that performs an action. If you'd like more guidance, take a look a the example project (included
in the ShareKit download). It has a separate example for sharing links, images, text, and files.
You need to add a way to allow the user to say 'hey, I want to share this!'. It is up to you where to place this button and even what it looks like. If your app has a UIToolbar or UINavigationBar, a common practice
is adding a UIBarButtonItem with theUIBarButtonSystemItemAction system
item style.
This icon has become the standard for sharing amongst iOS apps.
An example may look like:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)]
![](http://www.getsharekit.com/i/install/actionSheet.png)
Handling the Button Action
After you've added a button and set a target action to call when it's pushed, it's finally time to call ShareKit.A user's entry point into ShareKit is an actionsheet. This actionsheet displays the user's most used services and a more button for additional options.
The actionsheet will only display services that can respond to the item you want to share. So the first step is to create an
object (SHKItem) that describes what you want to share (a url, image, text, or file). With that item, you create an actionsheet and display it to the user.
Here are the 3 steps together. In this example we'll share a URL:
- (void)myButtonHandlerAction { // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionSheet showFromToolbar:navigationController.toolbar]; }
That's it! ShareKit will take over from there and handle everything else. This includes logging the user in to their selected service, allowing them to edit the share
item, displaying activity indicators, and even sharing offline.
Note: How/Where you display the action sheet is up to you. On an iPad you may want to display this as a popover from your share button. For all possible options, take a look at the UIActionSheetdocumentation.
To see examples sharing other types of content (images, text, or files) check out the complete
documentation or example project included in the ShareKit download.
Step 5: Offline Sharing
If your app can be used without an internet connection, you should support offline sharing. Luckily, this means only adding one additional line of code.Most ShareKit services support offline sharing. This means when a user shares something while they are disconnected, ShareKit will store it and wait to send until they are connected again.
You just need to tell ShareKit when to retry these offline items. A good time to do this is when the app is opened. Simply add this line when you want ShareKit to try resending the items:
相关文章推荐
- 微信分享缩略图,如何增加微信朋友圈分享链接的小图片? facebook、google+、twitter等分享的标签
- 一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
- 一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
- 一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
- 一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等 (使用 iOS6 自带的 social.framework)
- IOS进阶之Social.framework一键分享文字图片到新浪微博,facebook,twitter 还有保存打印等
- social.framework 实现分享文字图片等到新浪微博,twitter,facebook,保存和打印。
- 微信公众号一次二次转发链接地址是IP和图片不显示,转换成文字和图片分享到朋友圈问题
- 安卓之文字,链接,图片,音乐,分享功能的实现
- 国外热门网站的分享功能实现:facebook,twitter,google+1,tumblr等
- 微信分享链接带图片文字和描述
- iOS实现向多个社交网站(facebook,微信,微博,twitter等)分享的代码,支持iPhone和iPAD(分享链接编码)
- iOS 友盟微博分享文字+图片+链接实现
- Android Intent分享文件|分享图片|分享文字|功能的实现
- Android应用实现微信分享(微信好友,朋友圈),分享链接,图片,文字
- 登录一些安全网站,比如twitter/facebook,提示安全链接失败,或提示下载文件。
- 使用 iOS6 自带的 social.framework 实现分享文字图片等到新浪微博,twitter,
- 将企业协作与微信结合,明道打通微信实现从微信到明道的消息分享,目前已支持文字、图片以及链接
- 关于facebook分享不能显示图片链接问题