首页 > 解决方案 > UserNotifications related events

问题描述

I am working with an iOS app using UserNotifications.

When the user taps on a notification, this method is fired:

userNotificationCenter(_:didReceive:withCompletionHandler:)

I want to know if there is a method called when the notification arrives, independently of when the user reacts.

标签: iosswiftusernotifications

解决方案


Yes you can : https://developer.apple.com/documentation/usernotifications/unusernotificationcenterdelegate/1649518-usernotificationcenter Of course the app has to be open for that. you can not execute code if the app is closed. In some cases you can execute code if the app is in background but that required special authorisation.


推荐阅读