一旦 flurry session 开始,我需要获取 flurry session Id,使用以下代码启动 flurry session
Flurry.startSession("FLURRY_API_KEY", with: FlurrySessionBuilder
.init()
.withCrashReporting(true)
.withLogLevel(FlurryLogLevelAll))
使用 flurry session Id
Flurry.getSessionID()
如果我们在 session 开始后立即调用此方法, session ID 值为零。
在 android 中,以下 block 可用,它会在 flurry session 开始时执行,如何在 swift 中执行同样的操作。
.withListener(new FlurryAgentListener() {
最佳答案
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
}
关于swift - session 开始时的 Flurry 监听器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45587826/