HomeiOS Developmentios - Find out how to inform whether or not person opened...

ios – Find out how to inform whether or not person opened app utilizing push notification?


software(_:didFinishLaunchingWithOptions:)

That technique is simply name on a app launch, so meaning you already dealt with “Chilly-Begin” circumstances.

To deal with background state of affairs:

  1. Set UNUserNotificationCenter delegate
func software(_ software: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // 1) Set UNUserNotificationCenter delegate
        UNUserNotificationCenter.present().delegate = self
        /* the remainder of the code */
        ...
     
        return true
    }
  1. Monitor occasions in userNotificationCenter(_:didReceive:withCompletionHandler:)

extension AppDelegate: UNUserNotificationCenterDelegate {
    func userNotificationCenter(_ heart: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let userInfo = response.notification.request.content material.userInfo
        /* Monitor Occasions right here!!! */
        
        ...
        completionHandler()
    }
}

Because the doc of the delegation technique says:

The tactic will probably be known as on the delegate when the person responded to the notification by opening the applying, dismissing the notification or selecting a UNNotificationAction. The delegate have to be set earlier than the applying returns from software:didFinishLaunchingWithOptions:.

For my part, I believe we will take away the monitoring within the software(_:didFinishLaunchingWithOptions:), it isn’t examined, please confirm.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments