how to integrate flurry in ios using swift language

后端 未结 4 1602
走了就别回头了
走了就别回头了 2021-01-18 10:32

I want to integrate flurry in ios using swift language. I added the flurry sdk\'s two files : flurrylib.a and flurry.h and then entered my api key in project TestProject4-Br

相关标签:
4条回答
  • 2021-01-18 10:55

    Flurry Integration using Pods in Swift

    You need to import Flurry SDK as Follows

    import Flurry_iOS_SDK
    
     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
             Flurry.startSession("YOUR_API_KEY")
             Flurry.logEvent("Started Application")
        }
    
    0 讨论(0)
  • 2021-01-18 10:58

    If you are attempting to log events in the 'didFinishLaunchingWithOptions' using Flurry SDK 6.0.0, this is not possible due to a bug in that version of the SDK. It is possible to start a session from this function however. I was told this information by a Flurry support rep, and confirmed it in my own testing.

    0 讨论(0)
  • 2021-01-18 11:06

    You need to add a bridging header to your project. In that bridging header you import what you need in Swift and then you don't need to import it anywhere else. The iBook on using Swift and Obj-C alongside has a very good explanation on this.

    Actually, there is an explanation on Apple's Swift blog that says:

    To be safe, all components of your app should be built with the same version of Xcode and the Swift compiler to ensure that they work together.

    You can find more information here.

    0 讨论(0)
  • 2021-01-18 11:09

    I had the same issue and adding a bridging header worked for me. Here are the steps I followed.

    Note: If you already have a bridging file, skip the steps 2 to 4

    1. I dragged the Flurry folder to my Swift iOS project in XCode.
    2. I created a bridging header file by creating a new Objective-C header file (in XCode menu it's File/New/File/iOS/Source/Header File)
    3. I called the file name "PROJECTNAME-Bridging-Header.h" (replace PROJECTNAME with your XCode project name)
    4. In Project Build Settings, I searched for "Swift Compile - Code Generation" and there in "Objective-C Bridging Header" I entered the name of my new bridging file (PROJECTNAME-Bridging-Header.h) for debug and release values.
    5. Now, back in my bridging header file, I referenced the Flurry header file.

      #import "Flurry.h"

    6. In my AppDelegate.swift file, I could then call the Flurry methods using Swift:

      func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // setup Flurry Flurry.startSession(flurryKey) // replace flurryKey with your own key Flurry.setCrashReportingEnabled(true) // records app crashing in Flurry Flurry.logEvent("Start Application") // Example of even logging

    Hope it helps someone.

    0 讨论(0)
提交回复
热议问题