swift – ios: wish to know opening supply of the app whether or not is coming from deeplink / Push notification the when app launch or coming from background


I’m engaged on occasion implementation and I have to put user_visited occasion in app launch, coming from background mode, deeplink and push notification. So I’ve put my occasion in

  func software(_ software: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 DispatchQueue.fundamental.asyncAfter(deadline: .now() + 4.0) {
            self.trackUserVisitedEvent()
        }
}

 func applicationWillEnterForeground(_ software: UIApplication) {
 DispatchQueue.fundamental.asyncAfter(deadline: .now() + 4.0) {
            self.trackUserVisitedSegEvent()
        }
}

with delay of 4 sec as a result of I have to ship the app opening supply it is – direct, deeplink or push notification as a result of at the moment from my understanding applicationWillEnterForeground() is looking first and after that just for it’ll name userNotificationCenter() so I setup the supply on this in and after delay of 4 sec uservisited() will will get name

func userNotificationCenter(_ middle: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        SegmentEventData.shared.setUp(appSource: "PN", branchCampaign: "", branchMedium: "")

}

and identical case is going on with department deeplink it’ll take 3-4 sec to course of the info and get to know the deeplink – information current or coming from deeplink .

  Department.getInstance().initSession(launchOptions: launchOptions) { (params, error) in   
  SegmentEventData.shared.setUp(appSource: "Department deeplink", branchCampaign: marketing campaign, branchMedium: medium)
                }

So after 4 sec my uservisited() occasion will get known as with the right supply. However this timer is producing some random bug additionally. I wish to take away the timer.
I wish to know is there some other strategy to get the supply of app.
Can some one Plz assist on this context.
Thanks upfront..

Observe – I cann’t name occasion two time or there is no such thing as a different occasion to trace the supply, PM desires so as to add supply on this occasion solely.

Leave a Reply