Skip to content

Commit

Permalink
HandOff is now working
Browse files Browse the repository at this point in the history
However, the result is currently just logged to the screen - need to
extract the activity result
  • Loading branch information
Sam Davies committed Nov 24, 2014
1 parent 3c59c13 commit 6cfcb0b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions 38-handoff/MapOff/MapOff.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@
224D13651A11199C00A53AFB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
224D13661A11199C00A53AFB /* Build configuration list for PBXNativeTarget "MapOffTests" */ = {
isa = XCConfigurationList;
Expand All @@ -415,6 +416,7 @@
224D13681A11199C00A53AFB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
10 changes: 10 additions & 0 deletions 38-handoff/MapOff/MapOff/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Override point for customization after application launch.
return true
}

func application(application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool {
println("Will continue \(userActivityType)")
return true
}

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]!) -> Void) -> Bool {
println("Continuing...")
return true
}

}

4 changes: 4 additions & 0 deletions 38-handoff/MapOff/MapOff/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSUserActivityTypes</key>
<array>
<string>com.shinobicontrols.MapOff.viewport</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand Down
9 changes: 7 additions & 2 deletions 38-handoff/MapOff/MapOff/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ class ViewController: UIViewController, MKMapViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
userActivity = NSUserActivity(activityType: "com.shinobicontrols.MapOff.viewport")
userActivity?.becomeCurrent()
let activityType = "com.shinobicontrols.MapOff.viewport"
if userActivity?.activityType != activityType {
userActivity?.invalidate()
userActivity = NSUserActivity(activityType: activityType)
}

userActivity?.needsSave = true
mapView.delegate = self
}

Expand Down

0 comments on commit 6cfcb0b

Please sign in to comment.