3.2.4. Setting up Tracking of App Launch Sources

Custom Setup Guide

🚧

Before you begin, make sure you’ve completed these steps:

In order for Mindbox to correctly process app login, you’ll need to slightly edit the AppDelegate.swift file:

import Mindbox

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate { 

  func application(
    _ application: UIApplication, 
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    ...
    Mindbox.shared.track(.launch(launchOptions))

    return true
  }

  func application(
    _ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
  ) -> Bool {
    // Transmit the URL if the app is opened using a universalLink
    Mindbox.shared.track(.universalLink(userActivity))
    return true
  }


  //    MARK: didReceive response
  //    The function to process push notification clicks
  func userNotificationCenter(
    _ center: UNUserNotificationCenter, 
    didReceive response: UNNotificationResponse, 
    withCompletionHandler completionHandler: @escaping () -> Void) {

    Mindbox.shared.track(.push(response))
    completionHandler()
  }
}