FIRAnalytics(AppDelegate)
Provides App Delegate handlers to be used in your App Delegate.
To save time integrating Firebase Analytics in an application, Firebase Analytics does not
require delegation implementation from the AppDelegate if neither SwiftUI nor UIScene lifecycle
is adopted. Instead this is automatically done by Firebase Analytics. Should you choose instead
to delegate manually, you can turn off the App Delegate Proxy by adding
FirebaseAppDelegateProxyEnabled into your app’s Info.plist and setting it to boolean NO
, and
adding the methods in this category to corresponding delegation handlers.
To handle Universal Links, you must return true
in
UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:)
.
-
Handles events related to a URL session that are waiting to be processed.
If SwiftUI lifecycle is adopted, call this method from
UIApplicationDelegate.application(_:handleEventsForBackgroundURLSession:completionHandler:)
in your app delegate.If SwiftUI lifecycle is not adopted, Firebase Analytics does not require delegation implementation from the AppDelegate. If you choose instead to delegate manually, you can set FirebaseAppDelegateProxyEnabled to boolean
NO
in your app’s Info.plist and call this method fromUIApplicationDelegate.application(_:handleEventsForBackgroundURLSession:completionHandler:)
in your app delegate.
Declaration
Swift
class func handleEvents(forBackgroundURLSession identifier: String) async
Parameters
identifier
The identifier of the URL session requiring attention.
completionHandler
The completion handler to call when you finish processing the events. Calling this completion handler lets the system know that your app’s user interface is updated and a new snapshot can be taken.
-
Handles the event when the app is launched by a URL (custom URL scheme or universal link).
If SwiftUI lifecycle is adopted, use
onOpenURL(perform:)
to register a handler and call this method in the handler.If UIScene lifecycle is adopted, call this method from
UISceneDelegate.scene(_:willConnectTo:options:)
andUISceneDelegate.scene(_:openURLContexts:)
when the URL contexts are available.If neither SwiftUI nor UIScene lifecycle is adopted, Firebase Analytics does not require delegation implementation from the AppDelegate. If you choose instead to delegate manually, you can set FirebaseAppDelegateProxyEnabled to boolean
NO
in your app’s Info.plist and call this method fromUIApplicationDelegate.application(_:open:options:)
in your app delegate.
Declaration
Swift
class func handleOpen(_ url: URL)
Parameters
url
The URL resource to open. This resource can be a network resource or a file.
-
Handles the event when the app receives data associated with user activity that includes a Universal Link.
If SwiftUI lifecycle is adopted, use
onOpenURL(perform:)
to register a handler and callAnalytics.handleOpen(_:)
instead in the handler.If UIScene lifecycle is adopted, call this method from
UISceneDelegate.scene(_:willConnectTo:options:)
andUISceneDelegate.scene(_:continue:)
when NSUserActivity is available. See the Apple doc for more details.If neither SwiftUI nor UIScene lifecycle is adopted, Firebase Analytics does not require delegation implementation from the AppDelegate. If you choose instead to delegate manually, you can set FirebaseAppDelegateProxyEnabled to boolean
NO
in your app’s Info.plist and call this method fromUIApplication.application(_:continue:restorationHandler:)
in your app delegate.
Declaration
Swift
class func handleUserActivity(_ userActivity: Any)
Parameters
userActivity
The activity object containing the data associated with the task the user was performing.