Created
August 16, 2016 12:56
-
-
Save janodev/b3d0e1d3201664779aa32691fb40dbc1 to your computer and use it in GitHub Desktop.
Handle a text response
This file contains hidden or 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
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