swift - Handoff does not work with iOS 9 devices -


trying force handoff functionality work on iphone 5 , ipad air ios 9 devices , encounter issues think ios9-related - cannot check on ios 8 because have no devices system.

problem:

  1. i opening app on first device when main screen when user activity created
  2. on second device see on lock screen there activity related app
  3. i opening app , application:continueuseractivity:restorationhandler: not called on device have no ability show user same content presented on first device.

you can browse entire project on github: https://github.com/tomkowz/quotes

implementation details:

i've updated target's plist file , added nsuseractivitytypes.

<key>nsuseractivitytypes</key> <array>     <string>com.tomaszszulc.quotes.quoteslist</string>     <string>com.tomaszszulc.quotes.browsequote</string> </array> 

next i've created enum these declared types:

enum activitytype: string {     case browsequote = "com.tomaszszulc.quotes.browsequote"     case quoteslist = "com.tomaszszulc.quotes.quoteslist" } 

when user on main screen i'm starting nsuseractivity.

override func viewwillappear(animated: bool) {     super.viewwillappear(animated)     quotes = quote.findall(coredatastack.sharedinstance().maincontext)     tableview.reloaddata()     startuseractivity() }  override func viewwilldisappear(animated: bool) {     super.viewwilldisappear(animated)     useractivity?.invalidate() }  func startuseractivity() {     let activity = nsuseractivity(activitytype: activitytype.quoteslist.rawvalue)     activity.title = "viewing quotes list"     useractivity = activity     useractivity?.becomecurrent() } 

the second type of activity activates when user goes details of selected item. here views flow:

uinavigationcontroller -> (root) quoteslistviewcontroller -> (push) quotedetailsviewcontroller 

here code creating user activity in quotedetailsviewcontroller:

override func viewwillappear(animated: bool) {     super.viewwillappear(animated)     useractivity = viewmodel.useractivity // (viewmodel) quote.useractivity     useractivity?.becomecurrent() }  override func viewdiddisappear(animated: bool) {     super.viewdiddisappear(animated)     useractivity?.invalidate() } 

and viewmodel.useractivity calls:

extension quote {     @available(ios 8.0, *)     var useractivity: nsuseractivity {         let activity = nsuseractivity(activitytype: activitytype.browsequote.rawvalue)         activity.title = "reading " + self.author + " quote"         activity.userinfo = [quoteuseractivitykey.identifier.rawvalue: self.identifier]         // core spotlight support         if #available(ios 9.0, *) {             activity.contentattributeset = self.searchableitemattributeset()             activity.keywords = set([self.author])             activity.eligibleforsearch = true             activity.eligibleforhandoff = true         }          return activity     } } 

thank in advance!

if getting indicator on second device seeing potential handoff, "good" reason why application:continueuseractivity:restorationhandler:isn't called is:

this method not called if either application:willfinishlaunchingwithoptions: or application:didfinishlaunchingwithoptions: returns no.

the other reason handoff "doesn't work" if devices not logged same icloud account. see indicator, not in case.


Comments