Top Banner
These are confidential sessions—please refrain from streaming, blogging, or taking pictures Social Engineering Session 306 Integrating with Facebook, Twitter, and Sina Weibo Lestat Ali iOS Software Engineer Julien Robert OS X Software Engineer
226

Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Dec 01, 2015

Download

Documents

foufoutos73

Session 306 - Integrating With Facebook, Twitter and Sina Weibo
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

These are confidential sessions—please refrain from streaming, blogging, or taking pictures

Social Engineering

Session 306

Integrating with Facebook, Twitter, and Sina Weibo

Lestat AliiOS Software Engineer

Julien RobertOS X Software Engineer

Page 2: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—iOS 6

Page 3: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—iOS 6

Twitter

Page 4: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—iOS 6

Twitter Facebook

Page 5: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—iOS 6

Twitter Sina WeiboFacebook

Page 6: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—Mountain Lion

Page 7: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks—Mountain Lion

Page 8: Session 306 - Integrating With Facebook, Twitter and Sina Weibo
Page 9: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Shareable Content

Text

Images

Movies

Files

Page 10: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Shareable Content

Text

Images

Movies

Files

Social Networks

...

Facebook

Twitter

Weibo

Page 11: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Your App

Shareable Content

Text

Images

Movies

Files

Social Networks

...

Facebook

Twitter

Weibo

Page 12: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Your App

Shareable Content

Text

Images

Movies

Files

Social Networks

...

Facebook

Twitter

Weibo

Page 13: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What You Will Learn

•UI integration on iOS•UI integration on OS X•Advanced integration

Page 14: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration

Page 15: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Your App

Shareable Content Social Networks

...

Text

Images

Movies

Files

Facebook

Twitter

Weibo

Page 16: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Your App

Shareable Content Social Networks

...

Text

Images

Movies

Files

Facebook

Twitter

Weibo

UIActivityViewController NSSharingServicePicker

Page 17: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Your App

Shareable Content Social Networks

...

Text

Images

Movies

Files

Facebook

Twitter

Weibo

UIActivityViewController NSSharingServicePicker

Page 18: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Benefits of Using Built-in UI

Page 19: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Benefits of Using Built-in UI

• Creates a consistent user experience

Page 20: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Benefits of Using Built-in UI

• Creates a consistent user experience•Uses single sign-on

Page 21: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Benefits of Using Built-in UI

• Creates a consistent user experience•Uses single sign-on• Easy to integrate

Page 22: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Benefits of Using Built-in UI

• Creates a consistent user experience•Uses single sign-on• Easy to integrate• Improves over time

Page 23: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration on iOS

Page 24: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController

Page 25: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController

Page 26: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController

Page 27: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController Presentation

NSString *textToShare = @”Hello World!”;UIImage *imageToShare = [UIImage imageNamed:@”world.png”];NSArray *activityItems = @[textToShare, imageToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:nil];

Page 28: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController Presentation

NSString *textToShare = @”Hello World!”;UIImage *imageToShare = [UIImage imageNamed:@”world.png”];NSArray *activityItems = @[textToShare, imageToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:nil];

Page 29: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController Presentation

NSString *textToShare = @”Hello World!”;UIImage *imageToShare = [UIImage imageNamed:@”world.png”];NSArray *activityItems = @[textToShare, imageToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:nil];

Page 30: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UIActivityViewController Presentation

NSString *textToShare = @”Hello World!”;UIImage *imageToShare = [UIImage imageNamed:@”world.png”];NSArray *activityItems = @[textToShare, imageToShare];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

[self presentViewController:activityVC animated:YES completion:nil];

Page 31: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Targeted Integration

Page 32: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Targeted Integration

Facebook Sheet Tweet Sheet Weibo Sheet

Page 33: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Twitter Framework

Page 34: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Twitter Framework

• Twitter framework is deprecated

Page 35: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Twitter Framework

• Twitter framework is deprecated•Do not use TWTweetComposeViewController

Page 36: Session 306 - Integrating With Facebook, Twitter and Sina Weibo
Page 37: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

Page 38: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Twitter

Page 39: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

Twitter

Page 40: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

Twitter

Facebook

Page 41: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

Twitter

Facebook

Sina Weibo

Page 42: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

• Expands on Twitter framework• Provides SLComposeViewController• Factory for sharing sheets[SLComposeViewController composeViewControllerForType:]

Page 43: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

SLComposeViewControllerSpecifying the service type

Page 44: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

SLComposeViewControllerSpecifying the service type

Facebook Sheet Tweet Sheet Weibo Sheet

Page 45: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

SLComposeViewControllerSpecifying the service type

SLServiceTypeFacebook Tweet Sheet Weibo Sheet

Page 46: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

SLComposeViewControllerSpecifying the service type

SLServiceTypeFacebook SLServiceTypeTwitter Weibo Sheet

Page 47: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

SLComposeViewControllerSpecifying the service type

SLServiceTypeFacebook SLServiceTypeTwitter SLServiceTypeSinaWeibo

Page 48: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting an SLComposeViewController

SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForType:SLServiceTypeFacebook];

[facebookPostVC setInitialText:@”Hello World!”];

[facebookPostVC addImage:[UIImage imageNamed:@”world.png”]];

[self presentViewController:facebookPostVC animated:YES completion:nil];

Page 49: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting an SLComposeViewController

SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForType:SLServiceTypeFacebook];

[facebookPostVC setInitialText:@”Hello World!”];

[facebookPostVC addImage:[UIImage imageNamed:@”world.png”]];

[self presentViewController:facebookPostVC animated:YES completion:nil];

Page 50: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting an SLComposeViewController

SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForType:SLServiceTypeFacebook];

[facebookPostVC setInitialText:@”Hello World!”];

[facebookPostVC addImage:[UIImage imageNamed:@”world.png”]];

[self presentViewController:facebookPostVC animated:YES completion:nil];

Page 51: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting an SLComposeViewController

SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForType:SLServiceTypeFacebook];

[facebookPostVC setInitialText:@”Hello World!”];

[facebookPostVC addImage:[UIImage imageNamed:@”world.png”]];

[self presentViewController:facebookPostVC animated:YES completion:nil];

Page 52: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting an SLComposeViewController

SLComposeViewController *facebookPostVC = [SLComposeViewController composeViewControllerForType:SLServiceTypeFacebook];

[facebookPostVC setInitialText:@”Hello World!”];

[facebookPostVC addImage:[UIImage imageNamed:@”world.png”]];

[self presentViewController:facebookPostVC animated:YES completion:nil];

Page 53: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration on OS X

Julien RobertOS X Software Engineer

Page 54: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePickerShare Menu

Page 55: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePickerShare Menu

•Menu of services

Page 56: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePickerShare Menu

•Menu of services• Shows only available services

Page 57: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePickerShare Menu

•Menu of services• Shows only available services• Can be customized

Page 58: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePickerShare Menu

•Menu of services• Shows only available services• Can be customized• Easiest way to share

Page 59: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Page 60: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Twitter

Page 61: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Twitter Facebook

Page 62: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Twitter Facebook

Flickr

Page 63: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Twitter

iMessage

Facebook

Flickr

Page 64: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Many Sharing Options

Twitter

iMessage

Facebook

AirDropFlickr

Page 65: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Networks

Sharing Architecture

Shareable Content

Page 66: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServicePicker Social Networks

Sharing Architecture

Shareable Content

Page 67: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingService

NSSharingService

NSSharingService

NSSharingServicePicker Social Networks

Sharing Architecture

Shareable Content

Page 68: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingService

NSSharingService

NSSharingService

Delegate

NSSharingServicePicker Social Networks

Sharing Architecture

Shareable Content

Page 69: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Delegate

NSSharingService

NSSharingService

NSSharingService

Delegate

NSSharingServicePicker Social Networks

Sharing Architecture

Shareable Content

Page 70: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What Can You Share?

Page 71: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What Can You Share?

• Basic types■ NSImage■ NSString, NSAttributedString■ NSURL (local or remote)

Page 72: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What Can You Share?

• Basic types■ NSImage■ NSString, NSAttributedString■ NSURL (local or remote)

• Custom types that implement NSPasteboardWriting

Page 73: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Adding a Sharing Menu to Your App

Page 74: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Adding a Sharing Menu to Your App

1. Create share button

Page 75: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Adding a Sharing Menu to Your App

1. Create share button2. On click, present

NSSharingServicePicker

Page 76: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Adding a Sharing Menu to Your App

1. Create share button2. On click, present

NSSharingServicePicker

3. Specify a delegate for the user-selected service

Page 77: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Adding a Sharing Menu to Your App

1. Create share button2. On click, present

NSSharingServicePicker

3. Specify a delegate for the user-selected service

4. Implement the delegate methods for the service

Page 78: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 79: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 80: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 81: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 82: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 83: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Creating the buttonAdding a Sharing Menu to Your App

NSButton *button = [[NSButton alloc] init];

[button setImage:[NSImage imageNamed:NSImageNameShareTemplate]];

[button sendActionOn:NSLeftMouseDownMask];

[button setTarget:self];

[button setAction:@selector(showServicePicker:)];

Page 84: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting the sharing menuAdding a Sharing Menu to Your App

- (void)showServicePicker:(id)sender {

NSArray *items = @[@"Hello world", anImage];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:items];

picker.delegate = self;

[picker showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];

}

Page 85: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting the sharing menuAdding a Sharing Menu to Your App

- (void)showServicePicker:(id)sender {

NSArray *items = @[@"Hello world", anImage];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:items];

picker.delegate = self;

[picker showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];

}

Page 86: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting the sharing menuAdding a Sharing Menu to Your App

- (void)showServicePicker:(id)sender {

NSArray *items = @[@"Hello world", anImage];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:items];

picker.delegate = self;

[picker showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];

}

Page 87: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting the sharing menuAdding a Sharing Menu to Your App

- (void)showServicePicker:(id)sender {

NSArray *items = @[@"Hello world", anImage];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:items];

picker.delegate = self;

[picker showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];

}

Page 88: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting the sharing menuAdding a Sharing Menu to Your App

- (void)showServicePicker:(id)sender {

NSArray *items = @[@"Hello world", anImage];

NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:items];

picker.delegate = self;

[picker showRelativeToRect:NSZeroRect ofView:sender preferredEdge:NSMinYEdge];

}

Page 89: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Delegate

Specifying the service delegateAdding a Sharing Menu to Your App

NSSharingServicePicker

Delegate

Page 90: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingService

Delegate

Specifying the service delegateAdding a Sharing Menu to Your App

NSSharingServicePicker

Delegate

Page 91: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingService

Delegate

Specifying the service delegateAdding a Sharing Menu to Your App

NSSharingServicePicker

Delegate

Page 92: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingService

Delegate

- (id)sharingServicePicker:(NSSharingServicePicker *)picker delegateForSharingService:(NSSharingService *)service

Specifying the service delegateAdding a Sharing Menu to Your App

NSSharingServicePicker

Delegate

Page 93: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceDelegateImplementing the Service Delegate

Page 94: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceDelegateImplementing the Service Delegate

• Called immediately before items are shared - (void)sharingService:(NSSharingService *)service willShareItems:(NSArray *)items

Page 95: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceDelegateImplementing the Service Delegate

• Called immediately before items are shared - (void)sharingService:(NSSharingService *)service willShareItems:(NSArray *)items

• Called immediately after items are shared - (void)sharingService:(NSSharingService *)service didShareItems:(NSArray *)items

Page 96: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceDelegateImplementing the Service Delegate

• Called immediately before items are shared - (void)sharingService:(NSSharingService *)service willShareItems:(NSArray *)items

• Called immediately after items are shared - (void)sharingService:(NSSharingService *)service didShareItems:(NSArray *)items

•When sharing fails - (void)sharingService:(NSSharingService *)service didFailToShareItems:(NSArray *)items error:(NSError *)error

Page 97: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceDelegateImplementing the Service Delegate

• Called immediately before items are shared - (void)sharingService:(NSSharingService *)service willShareItems:(NSArray *)items

• Called immediately after items are shared - (void)sharingService:(NSSharingService *)service didShareItems:(NSArray *)items

•When sharing fails - (void)sharingService:(NSSharingService *)service didFailToShareItems:(NSArray *)items error:(NSError *)error

•Watch out for NSUserCancelledError

Page 98: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

Page 99: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

•Have these ready

Page 100: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

•Have these ready■ Shared item’s frame

Page 101: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

•Have these ready■ Shared item’s frame■ Transition image

Page 102: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

•Have these ready■ Shared item’s frame■ Transition image■ Source window

Page 103: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Make sharing a beautiful user experienceAnimating the Share Sheet

•Have these ready■ Shared item’s frame■ Transition image■ Source window■ Content scope

Page 104: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

DemoIntegrating NSSharingServicePicker into an OS X App

Page 105: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

Page 106: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

•Give the frame of the shared item- (NSRect)sharingService: sourceFrameOnScreenForShareItem:(id)item

Page 107: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

•Give the frame of the shared item- (NSRect)sharingService: sourceFrameOnScreenForShareItem:(id)item

• Its transition image- (NSImage *)sharingService: transitionImageForShareItem:item contentRect:(NSRect *)contentRect

Page 108: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

•Give the frame of the shared item- (NSRect)sharingService: sourceFrameOnScreenForShareItem:(id)item

• Its transition image- (NSImage *)sharingService: transitionImageForShareItem:item contentRect:(NSRect *)contentRect

Page 109: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

•Give the frame of the shared item- (NSRect)sharingService: sourceFrameOnScreenForShareItem:(id)item

• Its transition image- (NSImage *)sharingService: transitionImageForShareItem:item contentRect:(NSRect *)contentRect

Page 110: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing item frame and transition imageAnimating the Share Sheet

•Give the frame of the shared item- (NSRect)sharingService: sourceFrameOnScreenForShareItem:(id)item

• Its transition image- (NSImage *)sharingService: transitionImageForShareItem:item contentRect:(NSRect *)contentRect

QLThumbnailGetContentRect

Page 111: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Providing source window and content scopeAnimating the Share Sheet

- (NSWindow *)sharingService:(NSSharingService *)service sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope

Page 112: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Content scopes—hints for the animationAnimating the Share Sheet

Page 113: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Content scopes—hints for the animationAnimating the Share Sheet

• From a listNSSharingContentScopeItem

Page 114: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Content scopes—hints for the animationAnimating the Share Sheet

• From a listNSSharingContentScopeItem

• Extracted from a larger contentNSSharingContentScopePartial

Page 115: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Content scopes—hints for the animationAnimating the Share Sheet

• From a listNSSharingContentScopeItem

• Extracted from a larger contentNSSharingContentScopePartial

•Whole documentNSSharingContentScopeFull

Page 116: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceTargeted Integration

Page 117: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceTargeted Integration

• Customize trigger UI

Page 118: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceTargeted Integration

• Customize trigger UI• Specify a service name

Page 119: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

NSSharingServiceTargeted Integration

• Customize trigger UI• Specify a service name• Same share sheets

Page 120: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

Page 121: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clicked

Page 122: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clickedservice = [NSSharingService sharingServiceNamed: NSSharingServiceNamePostOnTwitter];

Page 123: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clickedservice = [NSSharingService sharingServiceNamed: NSSharingServiceNamePostOnTwitter];

service.delegate = self;

Page 124: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clickedservice = [NSSharingService sharingServiceNamed: NSSharingServiceNamePostOnTwitter];

service.delegate = self;

[service performWithItems:items];

Page 125: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clickedservice = [NSSharingService sharingServiceNamed: NSSharingServiceNamePostOnTwitter];

service.delegate = self;

[service performWithItems:items];

• Enable your control conditionally

Page 126: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Presenting a Share Sheet

•When your trigger UI is clickedservice = [NSSharingService sharingServiceNamed: NSSharingServiceNamePostOnTwitter];

service.delegate = self;

[service performWithItems:items];

• Enable your control conditionallyenable = [service canPerformWithItems:items];

Page 127: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration Summary

Page 128: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration Summary

UIActivityViewController

Page 129: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration Summary

UIActivityViewController NSSharingServicePicker

Page 130: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

UI Integration Summary

UIActivityViewController NSSharingServicePicker

Page 131: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Communicating with a service on your ownAdvanced Integration

Page 132: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Sample Request

Your App Facebook Server

Page 133: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Sample Request

https://graph.facebook.com/meYour App Facebook Server

Page 134: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Sample Request

https://graph.facebook.com/meYour App Facebook Server

{ “id”: “12345”,“name”: “Lestat Ali”,“first_name”: “Lestat”,“last_name”: “Ali”,“username”: “lestat.ali”,“gender”: “male”,“locale”: “en_US”

}

Page 135: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Sample Request

https://graph.facebook.com/meYour App Facebook Server

{ “id”: “12345”,“name”: “Lestat Ali”,“first_name”: “Lestat”,“last_name”: “Ali”,“username”: “lestat.ali”,“gender”: “male”,“locale”: “en_US”

}

Page 136: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Overview

Page 137: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Overview

•Accessing user accounts

Page 138: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Overview

•Accessing user accounts• Creating requests

Page 139: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Overview

•Accessing user accounts• Creating requests•Dealing with permissions

Page 140: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

Page 141: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

• Provides SLRequest

Page 142: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Social Framework

• Provides SLRequest • Can talk to

■ Facebook■ Twitter■ Sina Weibo (1.0 only)

Page 143: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

Page 144: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

1. Request access to the user’s account

Page 145: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

1. Request access to the user’s account2. Get the user’s account

Page 146: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

1. Request access to the user’s account2. Get the user’s account3. Create an SLRequest

Page 147: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

1. Request access to the user’s account2. Get the user’s account3. Create an SLRequest4. Provide the SLRequest with the account

Page 148: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Using SLRequest

1. Request access to the user’s account2. Get the user’s account3. Create an SLRequest4. Provide the SLRequest with the account5. Send the SLRequest

Page 149: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing User Accounts

Page 150: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing User Accounts

•Accounts framework controls access

Page 151: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing User Accounts

•Accounts framework controls access• Request access with-[ACAccountStore requestAccessToAccountsWithType:withCompletionHandler:]

Page 152: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing User Accounts

•Accounts framework controls access• Request access with-[ACAccountStore requestAccessToAccountsWithType:withCompletionHandler:]

• For Facebook, need a special dictionary in Info.plist

Page 153: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 154: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 155: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 156: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 157: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 158: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 159: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Getting Access to Facebook Accounts

self.accountStore = [[ACAccountStore alloc] init];

ACAccountType *facebookAccountType = [self.accountStoreaccountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

[self.accountStore requestAccessToAccountsWithType:facebookAccountType withCompletionHandler:^(BOOL granted, NSError *e) {

if (granted) {NSArray *accounts = [self.accountStore accountsWithAccountType:facebookAccountType];

self.facebookAccount = [accounts lastObject];} else {

// Fail gracefully...}

}];

Page 160: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

Page 161: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with

Page 162: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with■ URL

Page 163: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with■ URL■ HTTP Method

Page 164: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with■ URL■ HTTP Method■ Parameters

Page 165: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with■ URL■ HTTP Method■ Parameters

• Set the account property

Page 166: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Building Your Request

• Initialize an SLRequest instance with■ URL■ HTTP Method■ Parameters

• Set the account property• Perform the request and handle the response

Page 167: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

We Take Care of Signing Requests

Page 168: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

We Take Care of Signing Requests

App

Twitter/Facebook/Weibo API

Page 169: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

OAuth

We Take Care of Signing Requests

App

Twitter/Facebook/Weibo API

Page 170: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

We Take Care of Signing Requests

App

Twitter/Facebook/Weibo API

Page 171: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 172: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 173: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 174: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 175: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 176: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 177: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 178: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Accessing a User’s Facebook Profile

NSURL *requestURL = [NSURL URLWithString:@”https://graph.facebook.com/me”];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:requestURL parameters:nil];

request.account = self.facebookAccount;

[request performRequestWithHandler:^(NSData *data, NSHTTPURLResponse *response, NSError *error) {// Handle the response...

}];

Page 179: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

DemoDaily Cat Facts

Kalle HaglundsiOS Software Engineer

Page 180: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Account Access

Page 181: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Account Access

•Account access is more nuanced than Twitter

Page 182: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Account Access

•Account access is more nuanced than Twitter•Need to request specific permissions

Page 183: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Account Access

•Account access is more nuanced than Twitter•Need to request specific permissions• Permissions are documented on Facebook’s website

Page 184: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

Page 185: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

•Add this dictionary to Info.plist under the key ACFacebookClientAccessInfo@{

ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

Page 186: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

•Add this dictionary to Info.plist under the key ACFacebookClientAccessInfo@{

ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

• In next seed, pass it as an argument when requesting access

Page 187: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

@{ ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

Page 188: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

@{ ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

Page 189: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

@{ ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

Page 190: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Facebook Access Dictionary

@{ ACFacebookAppIDKey: @”123456789”,ACFacebookAppVersionKey: @”1.0”, ACFacebookPermissionsKey: @[@”publish_stream”, ...], ACFacebookPermissionGroupKey: @”write”

}

Page 191: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Choosing rightFacebook Permission Group

ACFacebookPermissionGroupRead ACFacebookPermissionGroupWrite

user_about_me, user_birthday, ... publish_actions

friends_about_me, friends_birthday, ... publish_stream

email

Page 192: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Choosing rightFacebook Permission Group

ACFacebookPermissionGroupRead ACFacebookPermissionGroupWrite

user_about_me, user_birthday, ... publish_actions

friends_about_me, friends_birthday, ... publish_stream

email

Page 193: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Choosing rightFacebook Permission Group

ACFacebookPermissionGroupRead ACFacebookPermissionGroupWrite

user_about_me, user_birthday, ... publish_actions

friends_about_me, friends_birthday, ... publish_stream

email

Page 194: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Choosing rightFacebook Permission Group

ACFacebookPermissionGroupRead ACFacebookPermissionGroupWrite

user_about_me, user_birthday, ... publish_actions

friends_about_me, friends_birthday, ... publish_stream

email

Need permissions from both groups? ACFacebookPermissionGroupReadWrite

Page 195: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

The forbidden fruitFacebook Permissions

Page 196: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

The forbidden fruitFacebook Permissions

• Extended permissions cannot be requested using the iOS API

Page 197: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

The forbidden fruitFacebook Permissions

• Extended permissions cannot be requested using the iOS API■ Reading the user’s timeline

Page 198: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

The forbidden fruitFacebook Permissions

• Extended permissions cannot be requested using the iOS API■ Reading the user’s timeline■ Managing pages

Page 199: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

The forbidden fruitFacebook Permissions

• Extended permissions cannot be requested using the iOS API■ Reading the user’s timeline■ Managing pages■ More in the documentation

Page 200: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

Page 201: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

•Might lose access at any time

Page 202: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

•Might lose access at any time■ Token expiration

Page 203: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

•Might lose access at any time■ Token expiration■ User removes app from website

Page 204: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

•Might lose access at any time■ Token expiration■ User removes app from website■ User flips switch in Settings

Page 205: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

Page 206: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid

Page 207: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling

Page 208: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling-[ACAccountStore renewCredentialsForAccount:withHandler:]

Page 209: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling-[ACAccountStore renewCredentialsForAccount:withHandler:]

•On completion

Page 210: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling-[ACAccountStore renewCredentialsForAccount:withHandler:]

•On completionACAccountCredentialRenewalRenewed

Page 211: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling-[ACAccountStore renewCredentialsForAccount:withHandler:]

•On completionACAccountCredentialRenewalRenewedACAccountCredentialRenewalRejected

Page 212: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Managing Facebook Access

• If server returns error 190, access token is invalid•Attempt to renew by calling-[ACAccountStore renewCredentialsForAccount:withHandler:]

•On completionACAccountCredentialRenewalRenewedACAccountCredentialRenewalRejectedACAccountCredentialRenewalFailed

Page 213: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What If I Already Have FBConnect?

Page 214: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What If I Already Have FBConnect?

• Support will be automatic

Page 215: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

What If I Already Have FBConnect?

• Support will be automatic•After next seed

Page 216: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

More Information

Paul MarcosApplication Services [email protected]

DocumentationAccounts Frameworkhttps://developer.apple.com/library/ios/

Social Frameworkhttps://developer.apple.com/ue

Apple Developer Forumshttps://devforums.apple.com

Third-Party DocumentationFacebook SDKhttps://developers.facebook.com/docs/

Twitter APIhttps://dev.twitter.com/docs

Sina Weibo API http://open.weibo.com/wiki/

Page 217: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Labs

Social Integration Lab App Services Lab AThursday 3:15PM

Page 218: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

Page 219: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy

Page 220: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

Page 221: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

■ On OS X—NSSharingServicePicker

Page 222: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

■ On OS X—NSSharingServicePicker

•Advanced integration gives you more control

Page 223: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

■ On OS X—NSSharingServicePicker

•Advanced integration gives you more control■ Accounts framework allows access to user account

Page 224: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

■ On OS X—NSSharingServicePicker

•Advanced integration gives you more control■ Accounts framework allows access to user account■ Let SLRequest sign requests for you

Page 225: Session 306 - Integrating With Facebook, Twitter and Sina Weibo

Summary

•UI Integration is easy■ On iOS—UIActivityViewController

■ On OS X—NSSharingServicePicker

•Advanced integration gives you more control■ Accounts framework allows access to user account■ Let SLRequest sign requests for you

• FBConnect will get you automatic support

Page 226: Session 306 - Integrating With Facebook, Twitter and Sina Weibo