overshare / overshare-kit

A soup-to-nuts sharing library for iOS.
MIT License
1.82k stars 133 forks source link

OvershareKit

A soup-to-nuts sharing library for iOS.

NOTA BENE: OVERSHAREKIT IS NO LONGER UNDER ACTIVE DEVELOPMENT. SEE http://blog.jaredsinclair.com/post/90064823470/oversharekit-to-be-maintenance-only-for-ios-8

Table of Contents

Why OvershareKit?

Sharing is far too cumbersome to implement on iOS. UIActivityViewController is too limiting, and rolling your own library is too time-consuming. Most devs end up settling for underwhelming sharing options for lack of the time or inclination to make something better.

OvershareKit makes it trivial to add rich sharing options to your iOS apps. In a word, OvershareKit has everything:

Screenshot

Pull Requests and New Features

We happily accept any pull request that adds meaningful value for the OvershareKit community. Bug fixes can be submitted on any branch, but significant changes and new features must be submitted on the dev branch for wider testing and review. Our day-to-day work is done on the dev branch. Watch the dev branch for an idea of what’s coming.

OvershareKit also has a public Pivotal Tracker project available here.

How to Use OvershareKit

OvershareKit is designed to be dead simple for the easy cases, while still being flexible enough to scale up to more complex needs, and without breaking inbetween.

After including OvershareKit in your Xcode project (see the detailed requirements below), the steps to get started couldn't be easier:

1) Create an instance of OSKShareableContent, ideally via one of the convenient class-level constructors like contentFromURL:

2) Pass that shareable content to the OSKPresentationManager via one of the presentActivitySheetForContent: methods.

3) There is no step 3.

OvershareKit Versus UIActivityViewController

We are frequently asked why someone would use OvershareKit instead of UIActivityViewController (UIAVC) and UIActivity. UIAVC is great for apps that know they’ll never have a need for any of the following:

  1. Never need to integrate with more than one or two third party services.
  2. Never need to tweak the UI for the activity sheet and sharing screens.
  3. Never care to provide separate, media-specific content for each sharing type (email versus SMS, etc.)
  4. Never need to have multiple items such as a Copy Text versus a Copy Link in the same sheet.
  5. Don't mind that all non-system-provided activities get stuck with boring monochromatic icons.

Many apps can't fit comfortably within those restrictions, which is why we made OvershareKit.

The most important difference between UIAVC and OvershareKit is in how content is structured. UIAVC uses unstructured arrays of content (which contain one or more of a grab-bag of objects, usually strings, images and URLs). UIAVC lets each UIActivity decide which of these objects, if any, it will act upon and how. The shortcoming of this API design is that activities don't know anything about the context in which a sharing session is taking place. For example, the formatting for an email message generated from an Instagram post should look very different from an email generated from an RSS article. But with UIAVC, there's no easy way to communicate that context. Most crucially, it is impossible to do this using UIAVC without providing substitutes for the system-provided mail activities.

Activities should not be given that much responsibility over content. The content should be ready to consume before it is handed to an activity. Furthermore, the content should be formatted in a manner that is appropriate to each type of activity.

This is why OvershareKit uses an instance of OSKShareableContent that bristles with many flavors of OSKShareableContentItem. This API design allows the part of your app that has knowledge of context to prepare all the various types of OSKShareableContentItems before handing it off to an OvershareKit sharing session. This results in a more satisfying sharing experience for the user, and less overall hassle for the developer.

Architecture

OvershareKit has lots of classes, but here are the main players:

Authentication

For the most part, OvershareKit will handle all aspects of authentication by itself. There are several crucial exceptions to this which every app will need to be configured to handle:

Application-Specific Credentials

Some third-party services require application-specific credentials in order to authenticate user actions. The sample app that ships with OvershareKit has been configured to use some test app credentials if the compiler flag for DEBUG is set to 1.

You must not ship OvershareKit's test credentials in a production application. They may be revoked at any time. We will not be responsible for any consequences if that happens. Please see the next several paragraphs for more information on setting up application credentials.

You can provide your app's credentials via the customizationsDelegate property of OSKActivitiesManager. These credentials are represented by instances of OSKApplicationCredential.

The list of services currently requiring application credentials are:

If you have any questions about this setup process, don’t hesitate to ask.

URL Schemes

Dependencies

OvershareKit is almost entirely a standalone library. All of its categories and classes have been properly namespaced with the OSK prefix to avoid collisions.

There are two required external libraries, which are included as git submodules in the Depedencies directory:

The Google Plus framework in the Dependencies directory is not a submodule.

In-App Purchases

You can optionally configure certain activity types to require in-app purchase. OvershareKit does not handle purchasing or receipt validation, but it does handle the logic around presenting your custom purchasing view controller at the appropriate time. OvershareKit will even badge the activity icons with cute little price tags when they have not yet been purchased. See the header files for OSKActivitiesManager and OSKPurchasingViewController for more details.

So Much More

There’s a ton of stuff to work with in OvershareKit. All of the major and many of the minor classes have been documented with appledoc syntax. More documentation is coming. If you have questions, please reach out to us.

Contributors

Jared Sinclair

Jared Sinclair

Primary Author and API Design
Twitter: @jaredsinclair
App.net: @jaredsinclair

Jared is an independent iOS app designer and developer. He makes apps like Unread an RSS Reader and Riposte for App.net.

Justin Williams

Justin Williams

API Design & iOS Account Integration
Twitter: @justin
App.net: @justin

Justin is an independent iOS and Mac app developer at Second Gear. He is a frequent public speaker at tech events.

Apps Using OvershareKit

Recent additions are at the top of the list.

Cardasee
Modern Quick Notes.
Website | App Store

nvNotes
The professional Note-taking App that allows you to focus on writing.
Website | App Store

Unread
An RSS Reader
By Jared Sinclair
Website | App Store

Redd
A Reddit client for iOS 7.
By Craig Merchant
Website | App Store

Sunlit
Shared photos and stories, built with App.net.
By Manton Reece and Jonathan Hays
Website | App Store

App.net - Broadcast With Push
Never miss important news again with App.net Broadcast.
By App.net
Website | App Store

Attributions

OvershareKit contains portions of other open-source code, either verbatim or (more commonly) with some pruning and refactoring. The following projects were immensely helpful:

License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.