我正在做一个待办事项应用程序……我希望该应用程序在推送通知后处理一些代码。
我发现了一个可以在用户点击通知后处理一些代码的功能。我希望应用程序在推送通知后不仅要在用户点击通知后处理一些代码。有什么办法吗?
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let application = UIApplication.shared
if(application.applicationState == .active){
print("user tapped the notification bar when the app is in foreground")
}
if(application.applicationState == .inactive)
{
print("user tapped the notification bar when the app is in background")
}
completionHandler()
}