the roads to friendship
DESCRIPTION
Presentation about the ways to make iOS apps good citizens by implementing Inter-app communication.TRANSCRIPT
Hello
Who$am$I?• Antonio'Cabezuelo'Vivo
• Freelance'iOS'developer'since'2008.
• Camera+,'Kiosko.net,'FunBox,'and'many'others.
The$roads$to$friendship
The$roads$to$friendshipmaking'your'apps'be0er'ci2zens'using'Inter6app'communica2on
What%is%Inter,app%communica2on?
“Is$the$process$by$which$two$apps$in$the$same$device$talk$to$each$other$to$share$data$or$to$perform$ac8ons$relevant$to$the$context$of$
both$apps.”
—"me
Friendship*ways• Family(ma)ers
• Lendings
• Smart(friends
• Fluent(conversa8ons
Family• Apps%from%the%same%developer
• Use%a%shared'keychain1
• Use%an%app%group%NSUserDefaults-initWithSuiteName:
1"Example"at"h,p://shaune.com.au/ios6keychain6sharing6data6between6apps/
Lending• Apps%that%send/receive%data%to/from%other%apps
• Mul7ple%ways
• Via%"Open&in…"
• Via%Document&Provider%extensions
• Custom%URL&schemes%using%UIPasteboard
• Via%AppLinks
"Open&in…"• Allows'to'send/receive'files'to/from'other'apps.
• Use'UIActivityViewController'to'send.
• Set'CFBundleDocumentTypes'in'Info.plist'to'support'receiving'files
• Test'for'file:'url'scheme'in'UIApplica>onDelegate'method'
.applica1on:openURL:sourceApplica1on:annota1on:
Document)Provider• Allows'other'apps'to'access'the'documents'managed'by'your'app.
• Allows'your'app'to'access'documents'from'other'apps
• Accessed'by'any'app'using'a'UIDocumentPickerViewController
• Example'at'http://www.macstories.net/tutorials/implementing-ios-8-document-pickers/
Custom'URL'schemes2
• Every'app'can'add'support'for'mul$ple'custom'url'schemes.
• Configured'in'Info.plist'inside'URL*Types'sec:on
• To'launch'the'other'app'use:[[UIApplication sharedApplication] openURL:url];
• Send'data'via'url'parameters'or'UIPasteboard
2"h$p://handleopenurl.com
UIPasteboard
• Create'a'private'UIPasteboard
• Make'it'persistent
• Add,data'to'pasteboard'0ed'to'a'UTI
• Launch'friend'app'via'custom,URL,scheme'indica0ng'pasteboard'name
• Read,data'from'pasteboard'inside'friend'app
AppLinks3
• Cross&pla*orm,-open-source,-and-simple-mobile-deep&linking.
• A-way-to-link-app-content-from-outside-the-app.
• Promoted-by-Facebook
• Reference-implementaAon-in-Bolts4
4"h$ps://github.com/BoltsFramework/Bolts:iOS
3"h$p://applinks.org/documenta8on/
The$smart$friends
Offer%custom%func.onality%to%other%apps.
• Via%extensions
• Audio%apps%can%use%Inter*app-audio5%or%Audiobus6
6"h$p://audiob.us
5"h$ps://developer.apple.com/library/ios/samplecode/InterAppAudioSuite/Introduc<on/Intro.html
Ac#on&extensions• Allows'ac*ons'to'be'applied'to'different'content
• Through'UIActivityViewController
• Can'have'custom'UI'or'not.
Photo%extensions
• Allows'edi+ng'photos'inside'Photos.app'
• Can'only'be'one'for'each'type'(photo,'video)'in'a'containing'app.
• Photos.app'provides'original+adjustments'or'current'version'
• Must'support'both'device'orienta,ons
Fluent'conversa.ons
Apps$communicate$back&forth$using$URLs$with$custom$URL$schemes.
• Both&apps&must&know&the&protocol&used.
• Be5er&using&x"callback"url
• Much&be5er&and&easier&using&the&IAC-framework
x"callback"url7
Provide(a(standardized(means(for(iOS(developers(to(expose(and(document(the(methods(they(make(available(to(other(apps
URL$Structure
[scheme]://x-callback-url/[action]?[x-callback parameters]&[action parameters]
7"h$p://x)callback)url.com."Directory"at"h$p://philgr.com/library"
x"callback(parameters
• x"source"The"friendly"name"of"the"source"app"calling"the"ac6on
• x"success"URL"to"open"to"return"to"the"source"app"on"success
• x"error"URL"to"open"to"return"to"the"source"app"on"error
• x"cancel"URL"to"open"to"return"to"the"source"app"on"cancel
IAC$Framework
The$easiest$way$to$add$x"callback"url$support$to$your$app.
• Forget(about(parsing(complicated(URLs
• Use(Objec9ve;C(classes(with(callback(blocks
• Create(custom(classes(for(integra9ng(in(other(apps
h"ps://github.com/tapsandswipes/InterAppCommunica9on
Example
Adding&a&url&to&Instapaper&from&your&app.
Without'IAC
NSString *instapaperURL = [NSString stringWithFormat:@"x-callback-instapaper://x-callback-url/add?url=%@", [@"http://tapsandswipes.com" urlEncodedString];
NSUrl *url = [NSUrl urlWithString:instapaperURL];
if ([[UIApplication sharedApplication] canOpenURL:url]) { [UIApplication sharedApplication] openURL:url];}
With%IAC
[[InstapaperIACClient client] add:@"http://tapsandswipes.com"];
DEMO
"Other"!waysThere%are%ways%to%be%friendship%not%accepted%by%the%Mother'Ship
• Via%reminders
• Via%custom,contact%in%address%book
The$future$of$friendship(specula)ons)
• Open&Extensions&to&other&document&types&and&apps
• Standarize&x7callback7url&through&custom&interfaces
• Two&apps&on&screen&communica?ng&via&standard&APIs
Conclusions
Should'my'app'be'friendly?YES
“The%only%way%to%have%a%friend%is%to%be%one”
—"not"me
Should'my'app'be'friendly?YES
“The%only%way%to%have%a%friend%is%to%be%one”
—"Ralph"Waldo"Emerson
Why?• Makes'your'app'be.er.
• Adds'more'uses'to'your'app.
• Helps'other'apps'to'be'be.er.
Don’t&forget&to&always&add
CommonSense.frameworkto#all#your#projects
Thank&you
Contact'info
Twi$er:(@acvivo
e"mail:([email protected]
web:%h"p://tapsandswipes.com
Github:(h"p://github.com/tapsandswipes