Search code examples
swifthockeyapp

Hockey app did crash on last session


I'm using this function to detect if the app did crashed on last session, but in always returns the same result, no matter how and where i put "fatalError", or any other errors. What i'm doing wrong?

    private func didCrashInLastSessionOnStartup() -> Bool {

            //returns false
            NSLog("\(BITHockeyManager.sharedHockeyManager().crashManager.didCrashInLastSession)")

            //returns -1
            NSLog("\(BITHockeyManager.sharedHockeyManager().crashManager.timeIntervalCrashInLastSessionOccurred)")

            return (BITHockeyManager.sharedHockeyManager().crashManager.didCrashInLastSession) &&
                (BITHockeyManager.sharedHockeyManager().crashManager.timeIntervalCrashInLastSessionOccurred < 5)
        }

Here is my didFinishLaunchingWithOptions:

BITHockeyManager.sharedHockeyManager().configureWithIdentifier("<id>", delegate: self)
BITHockeyManager.sharedHockeyManager().crashManager.crashManagerStatus = .AutoSend;
BITHockeyManager.sharedHockeyManager().debugLogEnabled = true
BITHockeyManager.sharedHockeyManager().startManager()
BITHockeyManager.sharedHockeyManager().authenticator.authenticateInstallation();

if self.didCrashInLastSessionOnStartup() {
            NSLog("Crashed on last session")
        } else {
            self.setupApplication()
        }

And my delegate functions:

func crashManagerWillCancelSendingCrashReport(crashManager: BITCrashManager!) {
        if self.didCrashInLastSessionOnStartup() {
            self.setupApplication()
        }
    }

func crashManager(crashManager: BITCrashManager!, didFailWithError error: NSError!) {
        if self.didCrashInLastSessionOnStartup() {
            self.setupApplication()
        }
    }

func crashManagerDidFinishSendingCrashReport(crashManager: BITCrashManager!) {
        if self.didCrashInLastSessionOnStartup() {
            self.setupApplication()
        }
    }

Solution

  • The problem is that you are using additional 3rd party SDKs which incorporate a crash reporting feature and initialize those after the HockeySDK in your code. (Found that out via your support request and that information was never part of your question describing the situation)

    You can only use one 3rd party crash reporting library in your app, the last one you initialize will always be the only one that works.