I am trying to perform an action from a notification. And so far I can call the correct delegate functions, but after clicking on the application it is not brought to the fore.
Relevant Code:
@available(iOS 10.0, *) func registerCategory() -> Void{ print("register category") let callNow = UNNotificationAction(identifier: "call", title: "Call now", options: []) let clear = UNNotificationAction(identifier: "clear", title: "Clear", options: []) let category : UNNotificationCategory = UNNotificationCategory.init(identifier: "IDENT123", actions: [callNow, clear], intentIdentifiers: [], options: []) let center = UNUserNotificationCenter.currentNotificationCenter() center.setNotificationCategories([category]) } @available(iOS 10.0, *) func scheduleNotification(event : String, interval: NSTimeInterval) { print("schedule ", event) let content = UNMutableNotificationContent() content.title = event content.body = "body" content.categoryIdentifier = "CALLINNOTIFICATION" let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: interval, repeats: false) let identifier = "id_"+event let request = UNNotificationRequest.init(identifier: identifier, content: content, trigger: trigger) let center = UNUserNotificationCenter.currentNotificationCenter() center.addNotificationRequest(request) { (error) in } } @available(iOS 10.0, *) func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { print("willPresent") completionHandler([.Badge, .Alert, .Sound]) } @available(iOS 10.0, *) func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) { let notification: UNNotification = response.notification let UUID = notification.request.content.userInfo["UUID"] as! String switch (response.actionIdentifier) { case "COMPLETE": UNUserNotificationCenter.currentNotificationCenter().removeDeliveredNotificationsWithIdentifiers([UUID]) case "CALLIN": let call = Call() CalendarController.sharedInstance.fetchMeetingByUUID(UUID, completion: { (thisMeeting) -> Void in if(!CallIn.Yield(thisMeeting).ConferenceCallNumber.containsString("None")){ call._call(thisMeeting) }else{
I can hit the didReceiveNotificationResponse () delegate function with a breakpoint, and it performs some of the actions that I put there, but not as expected (it should launch a device call, instead it just rejects the notification list, and nothing happens, however when I manually open the application again, the call starts, as if there is no permission to open the application from the notification).
source share