Skip to content

Instantly share code, notes, and snippets.

@Marcocanc
Last active January 27, 2017 13:37
Show Gist options
  • Save Marcocanc/2cdf189f5b2596ce68db27d0fbda8f22 to your computer and use it in GitHub Desktop.
Save Marcocanc/2cdf189f5b2596ce68db27d0fbda8f22 to your computer and use it in GitHub Desktop.
External Intent Enum
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