+ All Categories
Home > Engineering > Apple continuity

Apple continuity

Date post: 16-Apr-2017
Category:
Upload: hem-dutt
View: 369 times
Download: 1 times
Share this document with a friend
27
Apple Continuity Presenter : Hem Dutt
Transcript
Page 1: Apple continuity

Apple ContinuityPresenter : Hem Dutt

Page 2: Apple continuity

Agenda

• What is Apple Continuity?

• What all Apple devices are compatible?

• Different Modules in detail.

• Demo.

• Development.

Page 3: Apple continuity

Apple Continuity• Continuity is new feature introduced with OS X Yosemite and

iOS 8.1 that lets you partner your iPhone with a Mac (or other iOS device) in order to:

1. Make and receive phone calls.

2. Send and receive text (SMS) or multimedia (MMS) messages.

3. Handoff files between devices.

4. Get online with Instant Hotspot.

5. Use AirDrop.

Page 4: Apple continuity

Compatibility

• Continuity isn’t compatible with all Macs or iOS devices. The chief factor is whether the Mac or iOS device features low-power Bluetooth, also known as Bluetooth 4.0.

• However, even if your device does not have Bluetooth 4.0, this only means your Mac is incompatible with most Continuity features. Phone call and SMS Continuity rely on Wi-Fi so might work fine.

Page 5: Apple continuity

Phone Calls• Set up your Mac to take and make Phone calls

1. Open the Settings app on all iOS devices (including iPhone) and tap the FaceTime entry,then slide the switch alongside iPhone Mobile Calls.

2. On Mac(s),open FaceTime and in preferences tick alongside “iPhone Cellular Calls” option.

3. All devices should share the same WiFi.

• iOS 9 is taking this to new levels by allowing devices to be on different networks.

Page 6: Apple continuity

Phone Calls

Page 7: Apple continuity

SMS/MMS• Set up SMS/MMS on Mac

1. open the Settings app on your iPhone, then tap the Messages heading.

2. You’ll see a list of any Macs or iOS devices logged into the same iCloud account.

3. Tapping the switch alongside any will pop-up a PIN prompt, and the PIN you need to type will be displayed on the Mac or iOS device.

4. Tapping the Allow button on the iPhone after entering the PIN will clear the dialog boxes on each device.

• Sending a text message on a Mac or iOS device is just like sending a message to an iMessage user, except you specify the recipient’s phone number in the To: field of the Messages app, or look them up in the iCloud address book by typing their name.

Page 8: Apple continuity

SMS/MMS

Page 9: Apple continuity

Handoff• For Handoff to work you’ll need to have

compatible apps installed on your Mac and iOS devices.

• At the moment these are mostly limited to Apple’s own apps (Safari, Maps, Notes, Calendar etc).

• Only a handful of third-party apps playing along too such as Pocket,NYTimes,The Wall Street Journal etc.

• No setup is required for Handoff to work.

Page 10: Apple continuity

Handoff• Compatible Mac devices:

1. MacBook Air (Mid 2011 or later)

2. MacBook Pro (Mid 2012 or later)

3. Retina MacBook Pro (All models)

4. iMac (Late 2012 or later)

5. Mac Mini (Mid 2011 or later)

6. Mac Pro (Late 2013 or later)

Page 11: Apple continuity

Handoff

Page 12: Apple continuity

Handoff

Page 13: Apple continuity

Instant Hotspot• If you’re not already connected to a Wi-Fi network, Instant

Hotspot lets you make use your iPhone’s data connection. This is also referred as data tethering.

• Instant Hotspot will only work if your mobile phone plan allows it. One way to quickly check is to open Settings, tap Mobile (or Mobile Data), and look for a heading that reads Personal Hotspot or Set Up Personal Hotspot. If it’s not there then you should get in touch with your provider.

• Using Instant Hotspot on your Mac is easy – just click the Wi-Fi icon at the top right of the desktop and select your iPhone from the list (you’ll only see it if you’re not already connected to Wi-Fi).

• No setup is needed on the iPhone.

Page 14: Apple continuity

Instant Hotspot

Page 15: Apple continuity

Airdrop• AirDrop is a way to transfer files between devices

that arrived on iPhones and iPads iOS 7.

• It has existed on Macs for even longer, but Macs and iOS devices were unable to communicate due to differences in the technology required.

• In Yosemite and iOS 8 Apple has made it possible to use AirDrop to share files between Mac and iOS devices.

• Like the other Continuity features, AirDrop won’t work on all Macs.

Page 16: Apple continuity

Development• From all features provided in continuity, we can develop third party

apps using Handoff.

Page 17: Apple continuity

Handoff Interactions• Handing off a user activity involves three

phases :

1. Create a user activity object for each activity the user engages in app.

2. Update the user activity object regularly with information about what the user is doing.

3. Continue the user activity on a different device when the user requests it.

Page 18: Apple continuity

Adopting Handoff• Identify the types of user activities that your app supports. For

example, an email app could support composing and reading messages as two separate user activities.

• For each activity type, your app needs to identify when an activity of that type begins and ends, and it needs to maintain up-to-date state data sufficient to enable the activity to continue on another device.

Page 19: Apple continuity

Adopting Handoff• User activities can be shared among any app signed with the

same team identifier, and you don’t need a one-to-one mapping between originating and resuming apps. For example, one app creates three different types of activities, and those activities are resumed by three different apps on the second device. This asymmetry can be a common scenario, given the preference for iOS apps to be smaller and more focused on a dedicated purpose than more comprehensive Mac apps.

• Document-based apps on iOS and OS X automatically support Handoff by automatically creating NSUserActivity objects for iCloud-based documents if the app’s Info.plist property list file includes a CFBundleDocumentTypes key of NSUbiquitousDocumentUserActivityType.

Page 20: Apple continuity

Implementing Handoff• Implementing Handoff in your app requires you to write code that uses APIs in

UIKit and AppKit.

• Creating the User Activity Object:

NSUserActivity* myActivity = [[NSUserActivity alloc] initWithActivityType: @"com.myCompany.myBrowser.browsing"];

// Initialise userInfo

NSURL* webpageURL = [NSURL URLWithString:@"http://www.myCompany.com"];

myActivity.userInfo = @{

@"docName" : currentDoc,

@"pageNumber" : self.pageNumber,

@"scrollPosition" : self.scrollPosition};myActivity.title = @"Browsing";

[myActivity becomeCurrent];

Page 21: Apple continuity

Implementing Handoff• Tracking a user activity:

// UIResponder and NSResponder have a userActivity property

NSUserActivity *currentActivity = [self userActivity];

// Build an activity type using the app's bundle identifier

NSString *bundleName = [[NSBundle mainBundle] bundleIdentifier];

NSString *myActivityType = [bundleName stringByAppendingString:@".selected-list"];

if(![[currentActivity activityType] isEqualToString:myActivityType]) {

[currentActivity invalidate];

currentActivity = [[NSUserActivity alloc] initWithActivityType:myActivityType];

[currentActivity setDelegate:self];

[currentActivity setNeedsSave:YES];

[self setUserActivity:currentActivity];

} else {

// Already tracking user activity of this type

[currentActivity setNeedsSave:YES];

}

Page 22: Apple continuity

Implementing Handoff• Responder override for updating an activity's state :

You can associate responder objects (inheriting from NSResponder on OS X or UIResponder on iOS) with a given user activity if you set the activity as the responder’s userActivity property. The system automatically saves the NSUserActivity object at appropriate times, calling the responder’s updateUserActivityState: override to add current data to the user activity object using the activity object’s addUserInfoEntriesFromDictionary: method.

- (void)updateUserActivityState:(NSUserActivity *)userActivity {

. . …

[userActivity setTitle: self.activityTitle];

[userActivity addUserInfoEntriesFromDictionary: self.activityUserInfo];

}

Page 23: Apple continuity

Implementing Handoff• Continuing an Activity:

Handoff automatically advertises user activities that are available to be continued on iOS and OS X devices that are in physical proximity to the originating device and signed into the same iCloud account as the originating device. When the user chooses to continue a given activity, Handoff launches the appropriate app and sends the app delegate messages that determine how the activity is resumed.

Implement the application:willContinueUserActivityWithType: method to let the user know the activity will continue shortly. Use the the application:continueUserActivity:restorationHandler: method to configure the app to continue the activity. The system calls this method when the activity object, including activity state data in its userInfo dictionary, is available to the continuing app.

Page 24: Apple continuity

Implementing Handoff- (BOOL)application:(NSApplication *)application continueUserActivity: (NSUserActivity *)userActivity restorationHandler: (void (^)(NSArray *))restorationHandler {

BOOL handled = NO;

// Extract the payload

NSString *type = [userActivity activityType];

NSString *title = [userActivity title];

NSDictionary *userInfo = [userActivity userInfo];

// Assume the app delegate has a text field to display the activity information

[appDelegateTextField setStringValue: [NSString stringWithFormat:@"User activity is of type %@, has title %@, and user info %@",

type, title, userInfo]];

restorationHandler(self.windowControllers);

handled = YES;

return handled;

}

Page 25: Apple continuity

Implementing Handoff• Continuation Streams:

If resuming an activity requires more data than can be efficiently transferred by the initial Handoff payload, a continuing app can call back to the originating app’s activity object to open streams between the apps and transfer more data. In this case, the originating app sets its NSUserActivity object’s Boolean property supportsContinuationStreams to YES, sets the user activity delegate, then calls becomeCurrent

• Setting up streams

NSUserActivity* activity = [[NSUserActivity alloc] init];

activity.title = @"Editing Mail";

activity.supportsContinuationStreams = YES;

activity.delegate = self;

[activity becomeCurrent];

Page 26: Apple continuity

Implementing Handoff• Requesting streams

- (BOOL)application:(UIApplication *)application continueUserActivity: (NSUserActivity *)userActivity

restorationHandler: (void(^)(NSArray *restorableObjects))restorationHandler

{

[userActivity getContinuationStreamsWithCompletionHandler:^(

NSInputStream *inputStream,

NSOutputStream *outputStream, NSError *error) {

// Do something with the streams

}];

return YES;

}

Page 27: Apple continuity

Best Practices• Transfer as small a payload as possible in the userInfo dictionary—3KB or less. The more

payload data you deliver, the longer it takes the activity to resume.

• When a large amount of data transfer is unavoidable, use streams, but recognise that they have a cost in terms of network setup and overhead.

• Plan for different versions of apps on different platforms to work well with each other or fail gracefully. Remember that the complementary app design can be asymmetrical—for example, a monolithic Mac app can route each of its activity types to smaller, special-purpose apps on iOS.

• Use reverse-DNS notation for your activity types to avoid collisions. If the activity pertains only to a single app, you can use the app identifier with an extra field appended to describe the activity type. For example, use a format such as com.<company>.<app>.<activity type>, as in com.myCompany.myEditor.editing. If you have a user activity that works across more than one app, you can drop the app field, as in com.myCompany.editing.

• To update the activity object’s userInfo dictionary efficiently, configure its delegate and set its needsSave property to YES whenever the userInfo needs updating. At appropriate times, Handoff invokes the delegate’s userActivityWillSave: callback, and the delegate can update the activity state.

• Be sure the delegate of the continuing app implements its application:willContinueUserActivityWithType: to let the user know the activity will be continued. The user activity object may not be available instantly.


Recommended