Here's my sample app
I've had some trouble with this in another app and I'm trying to figure out what I'm doing wrong; It works like this:
The thing is: even though the didReceiveRemoteNotification()-function should be called, I still get false value when starting the app which shows me, that for any reason this method does not get called. Why? Can you help me?
Method didReceiveRemoteNotification()
is not supposed to be called for local notifications... It's only for remote notifications (Push Notifications).
Use UNUserNotificationCenterDelegate
delegate method
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
See details here https://stackoverflow.com/a/44142742/1825618
Get delivered notifications (Only the ones Currently being displayed in notification center)
UNUserNotificationCenter.current().getDeliveredNotifications {
(notifications) in
// your code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.