Responding to data in the push

I’m facing a weird issue where if I let a push sit in the Notification Center for 3-5mins then when the push is tapped, the app does not respond to the data (just a url that opens in-app browser). If the user taps the push before that time it works as expected.

I have my app setup exactly like section 8.2 of the book. with the exception that my push also has a string with the boolean.

Also, I am wondering how does the system keep track of multiple push notifications when there is a single environment object that extends ObservedObject and has @Published fields. (like url and beach)

Welcome to the forums, @bipinbipin. For your first question unfortunately I can’t help you. I’ll have to point you to something like stackoverflow.com or the Apple developer forums.

For the second question, each push notification is handled individually. If you include the apns-collapse-id header (see chapter 3) then only the most recent notification is kept. The delegate methods are called when a notification arrives, and then what your app actually does with that data is up to you.

thanks for the quick reply. I’m noticing that if I send only 1 push it seems to work all the time. if I have several push’s each with different links and I want them to each retain that value. and this is all happening only when the user taps the push.

    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                didReceive response: UNNotificationResponse,
                                withCompletionHandler completionHandler: @escaping () -> Void) {
        defer { completionHandler() }
        
      let userInfo = response.notification.request.content.userInfo

      Messaging.messaging().appDidReceiveMessage(userInfo) 

        if let articleUrl = userInfo["articleLink"] {
            self.articleLink = ampStoryLinkFromLink(link: articleUrl as! String)
            self.showPushLink = true
        }
    }

articleLInk and showPushLink are both @Published fields in the NotificationDelegate.

thx!