1

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()
        }
    }
Alexey Kuznetsov
  • 159
  • 1
  • 13
  • A general point first: `authenticateInstallation` should be called after `startManager`. Second: please include how and where in your code you crash the app. Third: Make sure to crash the app without the Xcode debugger being attached to your app. Fourth: you can also contact HockeyApp via support, having a sample project might help to find the problem quicker. – Kerni Aug 23 '16 at 18:53
  • Fixed first point, result is the same. Second: no matter where i crash the app, for example put fatalError() or force unwrapped optional in setupApplication function, or in viewDidLoad of the initial view controller. And of course that's without debugger attached, just looking for deviceLogs in xCode organizer. @Kerni have any ideas? – Alexey Kuznetsov Aug 24 '16 at 11:52

1 Answers1

1

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.

Kerni
  • 15,241
  • 5
  • 36
  • 57