I'm trying to get a push notification
sent from server when user has my application in background, or closed and the notification came from server.
User clicks the push notification bar and the application opens.
This works, but I'm not sure how to get the notification object to make it seen
and count down badges.
I tried to add observer in my mainviewcontroller
NotificationCenter.default.addObserver(
self,
selector: #selector(applicationWillEnterForeground(_:)),
name: UIApplication.willEnterForegroundNotification,
object: nil)
I tried to add code to my AppDelegate
func applicationWillEnterForeground(_ application: UIApplication) {
print(">>>>applicationWillEnterForeground;AppDelegate")
}
This two blocks are responding, but I'm not sure how to access clicked notification object
I have tried
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void)
But after the push notification click, application is opening a webpage in safari, so no processing is happening in this method