Search code examples
swiftcrashlyticsuserid

where to implement setUserIdentifier function from crashlytics in swift


I am new to swift. I am now trying to implement crashlytics in to my app. I have followed the tutorial to implement it for basic report but I want to implement userID so that I know who has problem using my app. I have checked online and found setUserIdentifier function but I have no idea where to implement this function. Do I need to call this function in every page or in app delegate.swift? Please give me an example on how to implement this one function.

Thank you very much.


Solution

  •  let phoneID = UIDevice.currentDevice().identifierForVendor.UUIDString
     Fabric.with([Crashlytics()])
     Crashlytics.sharedInstance().setUserIdentifier(phoneID)
    

    I used this to solve the problem and get the phone id.