iOS push notification: how to detect if the user tapped on notification when the app is in background?

前端 未结 12 1686
情深已故
情深已故 2020-11-29 15:43

There are a lot of stackoverflow threads regarding this topic, but I still didn\'t find a good solution.

If the app is not in the background, I can check launc

12条回答
  •  半阙折子戏
    2020-11-29 16:09

    For iOS 10 and above put this in AppDelegate, to get to know notification is tapped(works even app is closed or open)

    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                    didReceive response: UNNotificationResponse,
                                    withCompletionHandler completionHandler: @escaping () -> Void) {
    print("notification tapped here")
    }
    

提交回复
热议问题