Crashlytics
@interface Crashlytics : NSObject
Crashlytics. Handles configuration and initialization of Crashlytics.
Note: The Crashlytics class cannot be subclassed. If this is causing you pain for testing, we suggest using either a wrapper class or a protocol extension.
-
The delegate can be used to influence decisions on reporting and behavior, as well as reacting to previous crashes.
Make certain that the delegate is setup before starting Crashlytics with startWithAPIKey:… or via +[Fabric with:…]. Failure to do will result in missing any delegate callbacks that occur synchronously during start.
Declaration
Swift
unowned(unsafe) var delegate: AnyObject? { get set }
Objective-C
@property (assign, readwrite, nonatomic, nullable) id delegate;
-
The recommended way to install Crashlytics into your application is to place a call to +startWithAPIKey: in your -application:didFinishLaunchingWithOptions: or -applicationDidFinishLaunching: method.
Note: Starting with 3.0, the submission process has been significantly improved. The delay parameter is no longer required to throttle submissions on launch, performance will be great without it.
Declaration
Swift
class func start(withAPIKey apiKey: String) -> Crashlytics
Objective-C
+ (nonnull Crashlytics *)startWithAPIKey:(nonnull NSString *)apiKey;
Parameters
apiKey
The Crashlytics API Key for this app
Return Value
The singleton Crashlytics instance
-
If you need the functionality provided by the CrashlyticsDelegate protocol, you can use these convenience methods to activate the framework and set the delegate in one call.
Declaration
Swift
class func start(withAPIKey apiKey: String, delegate: Any?) -> Crashlytics
Objective-C
+ (nonnull Crashlytics *)startWithAPIKey:(nonnull NSString *)apiKey delegate:(nullable id)delegate;
Parameters
apiKey
The Crashlytics API Key for this app
delegate
A delegate object which conforms to CrashlyticsDelegate.
Return Value
The singleton Crashlytics instance
-
Access the singleton Crashlytics instance.
Declaration
Swift
class func sharedInstance() -> Crashlytics
Objective-C
+ (nonnull Crashlytics *)sharedInstance;
Return Value
The singleton Crashlytics instance
-
The easiest way to cause a crash - great for testing!
Declaration
Swift
func crash()
Objective-C
- (void)crash;
-
The easiest way to cause a crash with an exception - great for testing.
Declaration
Swift
func throwException()
Objective-C
- (void)throwException;
-
Specify a user identifier which will be visible in the Crashlytics UI.
Many of our customers have requested the ability to tie crashes to specific end-users of their application in order to facilitate responses to support requests or permit the ability to reach out for more information. We allow you to specify up to three separate values for display within the Crashlytics UI - but please be mindful of your end-user’s privacy.
We recommend specifying a user identifier - an arbitrary string that ties an end-user to a record in your system. This could be a database id, hash, or other value that is meaningless to a third-party observer but can be indexed and queried by you.
Optionally, you may also specify the end-user’s name or username, as well as email address if you do not have a system that works well with obscured identifiers.
Pursuant to our EULA, this data is transferred securely throughout our system and we will not disseminate end-user data unless required to by law. That said, if you choose to provide end-user contact information, we strongly recommend that you disclose this in your application’s privacy policy. Data privacy is of our utmost concern.
Declaration
Swift
func setUserIdentifier(_ identifier: String?)
Objective-C
- (void)setUserIdentifier:(nullable NSString *)identifier;
Parameters
identifier
An arbitrary user identifier string which ties an end-user to a record in your system.
-
Specify a user name which will be visible in the Crashlytics UI. Please be mindful of your end-user’s privacy and see if setUserIdentifier: can fulfil your needs.
See
setUserIdentifier:
Declaration
Swift
func setUserName(_ name: String?)
Objective-C
- (void)setUserName:(nullable NSString *)name;
Parameters
name
An end user’s name.
-
Specify a user email which will be visible in the Crashlytics UI. Please be mindful of your end-user’s privacy and see if setUserIdentifier: can fulfil your needs.
See
setUserIdentifier:
Declaration
Swift
func setUserEmail(_ email: String?)
Objective-C
- (void)setUserEmail:(nullable NSString *)email;
Parameters
email
An end user’s email address.
-
Set a value for a for a key to be associated with your crash data which will be visible in the Crashlytics UI. When setting an object value, the object is converted to a string. This is typically done by calling -[NSObject description].
Declaration
Swift
func setObjectValue(_ va