Setup
Initialize SDK
In the AppDelegate
add the following line to the didFinishLaunchingWithOptions
method.
Additionally, if you'd like to enable freeze detection be sure to add the applicationInitialized
call after configure
.
Replace LASTCRASH_API_KEY
with your LastCrash API key:
import UIKit
import LastCrash
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
LastCrash.configure("LASTCRASH_API_KEY")
LastCrash.applicationInitialized()
return true
}
}
Optional Delegate
Setting the delegate is optional. If you would like to control the logic behind sending crash reports then implement the LastCrashReportSenderDelegate
interface and call setCrashReportSenderDelegate
. If no delegate is set then crash reports will be sent automatically.
The lastCrashReportSenderHandleCrash
method will be called when crash reports are available to send. This allows you to implement your own logic or ask the user for permission to send crash reports.
LastCrash.sendCrashes()
must be called to send the crash reports if the delegate is used.
import UIKit
import LastCrash
class AppDelegate: NSObject, UIApplicationDelegate, LastCrashReportSenderDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
LastCrash.configure("LASTCRASH_API_KEY")
LastCrash.applicationInitialized()
return true
}
func lastCrashReportSenderHandleCrash() {
print("Sending crash!")
LastCrash.sendCrashes()
}
}