Skip to content

Instantly share code, notes, and snippets.

@janodev
Created August 16, 2016 12:56
Show Gist options
  • Save janodev/b3d0e1d3201664779aa32691fb40dbc1 to your computer and use it in GitHub Desktop.
Save janodev/b3d0e1d3201664779aa32691fb40dbc1 to your computer and use it in GitHub Desktop.
Handle a text response
class NotificationViewController: UIViewController, UINotificationContentExtension
{
override func canBecomeFirstResponder() -> Bool {
return true
}
override var inputAccessoryView: UIView {
get { return inputView }
}
func didReceive(_ response: UNNotificationResponse,
completionHandler done: (UNNotificationContentExtensionResponseOption) -> Void)
{
if response.actionIdentifier == "comment" {
becomeFirstResponder()
textField.becomeFirstResponder()
}
if let textResponse = response as? UNTextInputNotificationResponse {
server.send(textResponse.userText) {
done(.dismiss)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment