У меня есть приложение, в котором я пытаюсь получить и обрабатывать SILENT push-уведомления.
Я регистрируюсь для APN следующим образом:
UNUserNotificationCenter.currentNotificationCenter().delegate = self
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert]) {(granted, error) in
if granted {
application.registerForRemoteNotifications()
}
}
Реализовано:
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
// Handle notification
}
func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {
// Handle notification
}
Приложение имеет UIBackgroundModes
fetch
и remote-notification
Содержимое APN выглядит следующим образом:
{
"aps":{
"content-available":1,
"badge":0
},
"action":"shareDelete",
"shareId":633
}
Когда приложение находится на переднем плане, userNotificationCenter(centre:withCompletionHandler:willPresentNotification)
запускается при получении уведомления, но когда приложение зашифровывается, ничего не происходит.
Я вижу, что APN получен путем изменения номера значка, но ничего не запускается в приложении.
Что мне не хватает?
(Также спросил на форумах Apple dev)