Last active
January 27, 2017 13:37
-
-
Save Marcocanc/2cdf189f5b2596ce68db27d0fbda8f22 to your computer and use it in GitHub Desktop.
External Intent Enum
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
enum ExternalIntent { | |
case content(id: String) | |
case timeline | |
case example | |
init?(launchOptions: [UIApplicationLaunchOptionsKey: Any]?) { | |
guard let launchOptions = launchOptions else { return nil } | |
if let url = launchOptions[.url] as? URL { | |
self.init(url: url) | |
} else if let shortcutItem = launchOptions[.shortcutItem] as? UIApplicationShortcutItem { | |
self.init(shortcutItem: shortcutItem) | |
} else if let remoteNotification = launchOptions[.remoteNotification] as? [AnyHashable: Any] { | |
self.init(remoteNotification: remoteNotification) | |
} else { | |
return nil | |
} | |
} | |
//MARK: Initializers | |
init?(remoteNotification notification: [AnyHashable: Any]) { | |
//implement remote notification parsing here | |
return nil | |
} | |
init?(url: URL) { | |
//implement universal links here | |
return nil | |
} | |
init?(shortcutItem: UIApplicationShortcutItem) { | |
//implement shortcut items here | |
return nil | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment