Handoff in iOS8

Handoff is all about making you work across all devices within proximity range. It uses BTLE (Bluetooth low energy or Bluetooth LE ) and iCloud account to pair devices. After pairing in iOS it display the current app icon in left corner of the lock screen, left side of home screen in multitasking switcher screen, On Mac it shows in right part of the dock and command + tab menu

Handoff supports live streaming between apps in two devices. Handoff works in between websites and apps as well.

Fundamental unit of handoff is an Activity (NSUserActivity). When we create an Activity it automatically brodcasts and shows up in paired devices. When user selects the Activity (i.e; select the app) the host is informed and asked for the detaled information, after that host sends the detailed package and the app get launched.

All applications from the same developer can exchange activities this is based on the team identifier. Applications don't have to claim;
  • the same activity type they create
  • any activity types, but can still create them
This is helpful when there are multiple apps in iOS for an app in OSX

Creating, Updating and Continuing Activity is supported by AppKit and UIKit, i.e; UIDocument, UIResponder now have a NSUserActivity property. In UIDocument based apps the activity is set in .plist and will be managed by OS itself. In UIResponder, when the app is in focus UIKit walks the view hierarchy and check for the Activity. Every time user focus the Activity it evokes the becomeCurrent method and invalidate when it finished. To manage user, Activity have userInfo property for minimal ammont of information. It is a dictonary and can store NSArray, NSData, NSDate, NSDictonary, NSNull, NSNumber, NSSet, NSString, NSUUID, NSURL..

UIApplicationDelegate have new method (i.e; application:continueUserActivity:restorationHandler:) which tells the delegate that the data for continuing an activity is available. This method have a optional block, restorationHandler which executes if your app creates or fetches objects to perform the task it must be called from the app’s main thread. restorationHandler has no return value and take restorableObjects as param which is an array of UIResponder or UIDocument objects representing objects you created or fetched in order to perform the operation.

When continued from another device NSUserActivityDelegate call userActivityWasContinued: which notifies the delegate that the user activity was continued on another device. This will helpful when more then two devices are paired and Handoff on the same app.

Post a Comment