पर नहीं लाया जाता है, मैं अधिसूचना से कार्रवाई को लागू करने की कोशिश कर रहा हूं। और अब तक मैं सही प्रतिनिधि कार्यों को ट्रिगर करने में सक्षम हूं, लेकिन ऐप को टैप करने के बाद अग्रभूमि में नहीं लाया गया है।आईओएस 10: स्थानीय अधिसूचना से एक कार्रवाई को टैप करने से एप को अग्रभूमि
प्रासंगिक कोड:
@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{
//will open detail view, in case that no number were detected
NSNotificationCenter.defaultCenter().postNotificationName("OpenDetailViewOfMeeting", object: self, userInfo: ["UUID":UUID])
}
})
UNUserNotificationCenter.currentNotificationCenter().removeDeliveredNotificationsWithIdentifiers([UUID])
default: // switch statements must be exhaustive - this condition should never be met
log.error("Error: unexpected notification action identifier: \(UUID)")
}
completionHandler()
}
मैं प्रतिनिधि समारोह didReceiveNotificationResponse() एक ब्रेकपाइंट साथ हिट करने के लिए कर रहा हूँ, और यह एक तरीका है कि उम्मीद है में कुछ कार्रवाई है कि मैं वहाँ डाल करता है, लेकिन नहीं (यह है डिवाइस-कॉल शुरू करने के लिए, इसके बजाय यह अधिसूचना सूची को खारिज कर देता है, और कुछ नहीं होता है, हालांकि जब मैं मैन्युअल रूप से ऐप को मैन्युअल रूप से खोलता हूं, तो कॉल शुरू होता है जैसे अधिसूचना से ऐप खोलने की कोई अनुमति नहीं है)।