Created
January 19, 2020 02:06
-
-
Save e-sung/96f599c1d908fc5ddd39fe9112f30fc7 to your computer and use it in GitHub Desktop.
Protocol that enables basic HandOff feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol HandOffable { | |
func setUpHandOff(for url: URL?) | |
} | |
extension HandOffable where Self: UIViewController { | |
public func setUpHandOff(for url: URL?) { | |
guard let url = url else { return } | |
guard let activtiyType = Bundle.main.bundleIdentifier else { return } | |
userActivity = NSUserActivity(activityType: activtiyType) | |
userActivity?.isEligibleForHandoff = true | |
userActivity?.webpageURL = url | |
userActivity?.becomeCurrent() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment