skabber

Jay Graves

iOS Sharing Services

Ole Begemann has a nice post on What iOS Should Learn from Android and Windows 8. Specifically the post is about how Android, Windows 8 and iOS implement the sharing of things. The short version is that both Android and Windows 8 include a generic way to share things between applications and iOS has a very specific few ways to share only certain things.

There has been a lot of “Back to the Mac” talk in the last year however I think iOS could take a page from the Mac in this scenario. OS X has had the ability to share different types of media between applications using what are called Services. You can probably find Services on your machine right now. Just select an image file in the Finder and then click Finder -> Services from the Menu. This is what mine looks like

Services_example
Take for example that “Upload with CloudApp”. The Cloud.app on my machine has registered a Service with the OS that accepts an image file.There are even more Services installed for sharing a URL
Services_url_example
Check out that Tweet Service. Thats provided by the official Twitter.app. It’s like a Twitter Share Sheet right here in OS X Lion.

The Technical Details

Applications can register the Services they support by declaring them in the Info.plist. Lets go back to Twitter.app and see what that declaration looks like.

All this boils down to mean any selected text is sent to the Twitter.app tweetService method as a NSString from the Pasteboard. This is what the method signature of that Service probably looks like in thw Twitter.app AppDelegate

- (void)tweetService:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error;

What if iOS had this?

Imagine if you could share a photo you took in Camera+ with Path without having to first save it to the Camera Roll and do a bunch of App Switching. The flow would go like this.

  1. Path registers a Service in it’s Info.plist telling iOS that it supports image files.
  2. Camera+ tells iOS it has an image to share.
  3. iOS presents a list op App Services that support image files.
  4. The user selectes a the Path App Service.
  5. Path is launched with the image data passed to it’s Service method that was registered in step #1.

If that sounds a bit like Déjà vu, it’s because it’s very similar to how iOS already supports Documents.

Photo_feb_23_10_33_52_pm

Does iOS already have this?

One of the things Apple touted about iOS 5 was that it had some new “System Wide Services” including Dictionary lookup provided by iBooks. This iOS 5 preview from Macworld references it.

Dictionary_service

I don’t see anything Service related in the iBooks Info.plist. That doesn’t mean that the frameworks to support this doesn’t already exist. Maybe it’s just not exposed to us yet.