Hi,
In chapter 11 I am unable to pick up the text response that is sent back by the user.
I have the map displaying fine, but when you type a response and press send nothing happens; the print statements are not triggered.
When the map is displayed in the notification the following appears in the output window:
2019-03-28 09:25:58.127576+0000 PushNotifications[21497:6295793] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-03-28 09:25:58.145576+0000 PushNotifications[21497:6295793] [MC] Reading from public effective user settings.
I am not sure what this means but it appears my didReceive( _:completionHander:) function is not being hit.
This is my NotificationViewController Code:
class NotificationViewController: UIViewController, UNNotificationContentExtension {
@IBOutlet var mapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any required interface initialization here.
}
func didReceive(_ notification: UNNotification) {
let userInfo = notification.request.content.userInfo
guard let latitude = userInfo["latitude"] as? CLLocationDistance,
let longitude = userInfo["longitude"] as? CLLocationDistance,
let radius = userInfo["radius"] as? CLLocationDistance else {
return
}
let location = CLLocation(latitude: latitude, longitude: longitude)
let region = MKCoordinateRegion(center: location.coordinate, latitudinalMeters: radius, longitudinalMeters: radius)
mapView.setRegion(region, animated: false)
}
func didReceive( _ response: UNNotificationResponse,completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) → Void) {
print("Processing Response")
defer { completion(.dismiss) }
guard let response = response as? UNTextInputNotificationResponse
else {
return
}
let text = response.userText
print("The user responded with: \(text)")
}
}
Thanks!