swiftflurryflurry-analytics

Flurry listener on start of session


I need to get flurry session Id once flurry session started, using following code to start flurry session

Flurry.startSession("FLURRY_API_KEY", with: FlurrySessionBuilder
                 .init()
                 .withCrashReporting(true)
                 .withLogLevel(FlurryLogLevelAll))

To get flurry session Id using

Flurry.getSessionID()

If we call this method immediately after the start of the session getting session Id value as zero.

In android, the following block is available which gets executed when flurry session started, how to do same in swift.

.withListener(new FlurryAgentListener() {


Solution

  •     import UIKit
        import Flurry_iOS_SDK
    
        @UIApplicationMain
        class AppDelegate: UIResponder, UIApplicationDelegate, FlurryDelegate {
    
            var window: UIWindow?
    
    
            func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
                // Override point for customization after application launch.
    
    
                Flurry.setDelegate(self)
    
                let builder = FlurrySessionBuilder.init()
                    .withAppVersion("1.0")
                    .withLogLevel(FlurryLogLevelAll)
                    .withCrashReporting(true)
                    .withSessionContinueSeconds(10)
    
                // Replace YOUR_API_KEY with the api key in the downloaded package
                Flurry.startSession("2WZ22NRSX8W52VKZBX9G", with: builder)
    
                return true
            }
    
         /*!
             *  @brief Invoked when analytics session is created
             *  @since 6.3.0
             *
             *  This method informs the app that an analytics session is created.
             *
             *  @see Flurry#startSession for details on session.
             *
             *  @param info A dictionary of session information: sessionID, apiKey
             */
    
            func flurrySessionDidCreate(withInfo info: [AnyHashable : Any]!) {
    
             //your session handling code here
    
            }
    

    Here is a screenshot highlighting the code added for the FlurryDelegate: enter image description here