added iOS source code
[wl-app.git] / iOS / Pods / Crashlytics / iOS / Crashlytics.framework / Headers / Crashlytics.h
1 //
2 //  Crashlytics.h
3 //  Crashlytics
4 //
5 //  Copyright (c) 2015 Crashlytics, Inc. All rights reserved.
6 //
7
8 #import <Foundation/Foundation.h>
9
10 #import "CLSAttributes.h"
11 #import "CLSLogging.h"
12 #import "CLSReport.h"
13 #import "CLSStackFrame.h"
14 #import "Answers.h"
15
16 NS_ASSUME_NONNULL_BEGIN
17
18 @protocol CrashlyticsDelegate;
19
20 /**
21  * Crashlytics. Handles configuration and initialization of Crashlytics.
22  *
23  * Note: The Crashlytics class cannot be subclassed. If this is causing you pain for
24  * testing, we suggest using either a wrapper class or a protocol extension.
25  */
26 @interface Crashlytics : NSObject
27
28 @property (nonatomic, readonly, copy) NSString *APIKey;
29 @property (nonatomic, readonly, copy) NSString *version;
30 @property (nonatomic, assign)         BOOL      debugMode;
31
32 /**
33  *
34  * The delegate can be used to influence decisions on reporting and behavior, as well as reacting
35  * to previous crashes.
36  *
37  * Make certain that the delegate is setup before starting Crashlytics with startWithAPIKey:... or
38  * via +[Fabric with:...]. Failure to do will result in missing any delegate callbacks that occur
39  * synchronously during start.
40  *
41  **/
42 @property (nonatomic, assign, nullable) id <CrashlyticsDelegate> delegate;
43
44 /**
45  *  The recommended way to install Crashlytics into your application is to place a call to +startWithAPIKey: 
46  *  in your -application:didFinishLaunchingWithOptions: or -applicationDidFinishLaunching:
47  *  method.
48  *
49  *  Note: Starting with 3.0, the submission process has been significantly improved. The delay parameter
50  *  is no longer required to throttle submissions on launch, performance will be great without it.
51  *
52  *  @param apiKey The Crashlytics API Key for this app
53  *
54  *  @return The singleton Crashlytics instance
55  */
56 + (Crashlytics *)startWithAPIKey:(NSString *)apiKey;
57 + (Crashlytics *)startWithAPIKey:(NSString *)apiKey afterDelay:(NSTimeInterval)delay CLS_DEPRECATED("Crashlytics no longer needs or uses the delay parameter.  Please use +startWithAPIKey: instead.");
58
59 /**
60  *  If you need the functionality provided by the CrashlyticsDelegate protocol, you can use
61  *  these convenience methods to activate the framework and set the delegate in one call.
62  *  
63  *  @param apiKey   The Crashlytics API Key for this app
64  *  @param delegate A delegate object which conforms to CrashlyticsDelegate.
65  *
66  *  @return The singleton Crashlytics instance
67  */
68 + (Crashlytics *)startWithAPIKey:(NSString *)apiKey delegate:(nullable id<CrashlyticsDelegate>)delegate;
69 + (Crashlytics *)startWithAPIKey:(NSString *)apiKey delegate:(nullable id<CrashlyticsDelegate>)delegate afterDelay:(NSTimeInterval)delay CLS_DEPRECATED("Crashlytics no longer needs or uses the delay parameter.  Please use +startWithAPIKey:delegate: instead.");
70
71 /**
72  *  Access the singleton Crashlytics instance.
73  *
74  *  @return The singleton Crashlytics instance
75  */
76 + (Crashlytics *)sharedInstance;
77
78 /**
79  *  The easiest way to cause a crash - great for testing!
80  */
81 - (void)crash;
82
83 /**
84  *  The easiest way to cause a crash with an exception - great for testing.
85  */
86 - (void)throwException;
87
88 /**
89  *  Specify a user identifier which will be visible in the Crashlytics UI.
90  *
91  *  Many of our customers have requested the ability to tie crashes to specific end-users of their
92  *  application in order to facilitate responses to support requests or permit the ability to reach
93  *  out for more information. We allow you to specify up to three separate values for display within
94  *  the Crashlytics UI - but please be mindful of your end-user's privacy.
95  *
96  *  We recommend specifying a user identifier - an arbitrary string that ties an end-user to a record
97  *  in your system. This could be a database id, hash, or other value that is meaningless to a
98  *  third-party observer but can be indexed and queried by you.
99  *
100  *  Optionally, you may also specify the end-user's name or username, as well as email address if you
101  *  do not have a system that works well with obscured identifiers.
102  *
103  *  Pursuant to our EULA, this data is transferred securely throughout our system and we will not
104  *  disseminate end-user data unless required to by law. That said, if you choose to provide end-user
105  *  contact information, we strongly recommend that you disclose this in your application's privacy
106  *  policy. Data privacy is of our utmost concern.
107  *
108  *  @param identifier An arbitrary user identifier string which ties an end-user to a record in your system.
109  */
110 - (void)setUserIdentifier:(nullable NSString *)identifier;
111
112 /**
113  *  Specify a user name which will be visible in the Crashlytics UI.
114  *  Please be mindful of your end-user's privacy and see if setUserIdentifier: can fulfil your needs.
115  *  @see setUserIdentifier:
116  *
117  *  @param name An end user's name.
118  */
119 - (void)setUserName:(nullable NSString *)name;
120
121 /**
122  *  Specify a user email which will be visible in the Crashlytics UI.
123  *  Please be mindful of your end-user's privacy and see if setUserIdentifier: can fulfil your needs.
124  *  
125  *  @see setUserIdentifier:
126  *
127  *  @param email An end user's email address.
128  */
129 - (void)setUserEmail:(nullable NSString *)email;
130
131 + (void)setUserIdentifier:(nullable NSString *)identifier CLS_DEPRECATED("Please access this method via +sharedInstance");
132 + (void)setUserName:(nullable NSString *)name CLS_DEPRECATED("Please access this method via +sharedInstance");
133 + (void)setUserEmail:(nullable NSString *)email CLS_DEPRECATED("Please access this method via +sharedInstance");
134
135 /**
136  *  Set a value for a for a key to be associated with your crash data which will be visible in the Crashlytics UI.
137  *  When setting an object value, the object is converted to a string. This is typically done by calling 
138  *  -[NSObject description].
139  *
140  *  @param value The object to be associated with the key
141  *  @param key   The key with which to associate the value
142  */
143 - (void)setObjectValue:(nullable id)value forKey:(NSString *)key;
144
145 /**
146  *  Set an int value for a key to be associated with your crash data which will be visible in the Crashlytics UI.
147  *
148  *  @param value The integer value to be set
149  *  @param key   The key with which to associate the value
150  */
151 - (void)setIntValue:(int)value forKey:(NSString *)key;
152
153 /**
154  *  Set an BOOL value for a key to be associated with your crash data which will be visible in the Crashlytics UI.
155  *
156  *  @param value The BOOL value to be set
157  *  @param key   The key with which to associate the value
158  */
159 - (void)setBoolValue:(BOOL)value forKey:(NSString *)key;
160
161 /**
162  *  Set an float value for a key to be associated with your crash data which will be visible in the Crashlytics UI.
163  *
164  *  @param value The float value to be set
165  *  @param key   The key with which to associate the value
166  */
167 - (void)setFloatValue:(float)value forKey:(NSString *)key;
168
169 + (void)setObjectValue:(nullable id)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance");
170 + (void)setIntValue:(int)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance");
171 + (void)setBoolValue:(BOOL)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance");
172 + (void)setFloatValue:(float)value forKey:(NSString *)key CLS_DEPRECATED("Please access this method via +sharedInstance");
173
174 /**
175  *  This method can be used to record a single exception structure in a report. This is particularly useful
176  *  when your code interacts with non-native languages like Lua, C#, or Javascript. This call can be
177  *  expensive and should only be used shortly before process termination. This API is not intended be to used
178  *  to log NSException objects. All safely-reportable NSExceptions are automatically captured by
179  *  Crashlytics.
180  *
181  *  @param name       The name of the custom exception
182  *  @param reason     The reason this exception occurred
183  *  @param frameArray An array of CLSStackFrame objects
184  */
185 - (void)recordCustomExceptionName:(NSString *)name reason:(nullable NSString *)reason frameArray:(CLS_GENERIC_NSARRAY(CLSStackFrame *) *)frameArray;
186
187 /**
188  *
189  * This allows you to record a non-fatal event, described by an NSError object. These events will be grouped and
190  * displayed similarly to crashes. Keep in mind that this method can be expensive. Also, the total number of
191  * NSErrors that can be recorded during your app's life-cycle is limited by a fixed-size circular buffer. If the
192  * buffer is overrun, the oldest data is dropped. Errors are relayed to Crashlytics on a subsequent launch
193  * of your application.
194  *
195  * You can also use the -recordError:withAdditionalUserInfo: to include additional context not represented
196  * by the NSError instance itself.
197  *
198  **/
199 - (void)recordError:(NSError *)error;
200 - (void)recordError:(NSError *)error withAdditionalUserInfo:(nullable CLS_GENERIC_NSDICTIONARY(NSString *, id) *)userInfo;
201
202 - (void)logEvent:(NSString *)eventName CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:");
203 - (void)logEvent:(NSString *)eventName attributes:(nullable NSDictionary *) attributes CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:");
204 + (void)logEvent:(NSString *)eventName CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:");
205 + (void)logEvent:(NSString *)eventName attributes:(nullable NSDictionary *) attributes CLS_DEPRECATED("Please refer to Answers +logCustomEventWithName:");
206
207 @end
208
209 /**
210  *
211  * The CrashlyticsDelegate protocol provides a mechanism for your application to take
212  * action on events that occur in the Crashlytics crash reporting system.  You can make
213  * use of these calls by assigning an object to the Crashlytics' delegate property directly,
214  * or through the convenience +startWithAPIKey:delegate: method.
215  *
216  */
217 @protocol CrashlyticsDelegate <NSObject>
218 @optional
219
220
221 - (void)crashlyticsDidDetectCrashDuringPreviousExecution:(Crashlytics *)crashlytics CLS_DEPRECATED("Please refer to -crashlyticsDidDetectReportForLastExecution:");
222 - (void)crashlytics:(Crashlytics *)crashlytics didDetectCrashDuringPreviousExecution:(id <CLSCrashReport>)crash CLS_DEPRECATED("Please refer to -crashlyticsDidDetectReportForLastExecution:");
223
224 /**
225  *
226  *  Called when a Crashlytics instance has determined that the last execution of the
227  *  application resulted in a saved report.  This is called synchronously on Crashlytics
228  *  initialization. Your delegate must invoke the completionHandler, but does not need to do so
229  *  synchronously, or even on the main thread. Invoking completionHandler with NO will cause the
230  *  detected report to be deleted and not submitted to Crashlytics. This is useful for
231  *  implementing permission prompts, or other more-complex forms of logic around submitting crashes.
232  *
233  *  Instead of using this method, you should try to make use of -crashlyticsDidDetectReportForLastExecution: 
234  *  if you can.
235  *
236  *  @warning Failure to invoke the completionHandler will prevent submissions from being reported. Watch out.
237  *
238  *  @warning Just implementing this delegate method will disable all forms of synchronous report submission. This can
239  *           impact the reliability of reporting crashes very early in application launch.
240  *
241  *  @param report            The CLSReport object representing the last detected report
242  *  @param completionHandler The completion handler to call when your logic has completed.
243  *
244  */
245 - (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report completionHandler:(void (^)(BOOL submit))completionHandler;
246
247 /**
248  *
249  *  Called when a Crashlytics instance has determined that the last execution of the
250  *  application resulted in a saved report. This method differs from
251  *  -crashlyticsDidDetectReportForLastExecution:completionHandler: in three important ways:
252  *
253  *    - it is not called synchronously during initialization
254  *    - it does not give you the ability to prevent the report from being submitted
255  *    - the report object itself is immutable
256  *
257  *  Thanks to these limitations, making use of this method does not impact reporting 
258  *  reliabilty in any way.
259  *
260  *  @param report The read-only CLSReport object representing the last detected report
261  *
262  */
263
264 - (void)crashlyticsDidDetectReportForLastExecution:(CLSReport *)report;
265
266 /**
267  *  If your app is running on an OS that supports it (OS X 10.9+, iOS 7.0+), Crashlytics will submit
268  *  most reports using out-of-process background networking operations. This results in a significant
269  *  improvement in reliability of reporting, as well as power and performance wins for your users.
270  *  If you don't want this functionality, you can disable by returning NO from this method.
271  *
272  *  @warning Background submission is not supported for extensions on iOS or OS X.
273  *
274  *  @param crashlytics The Crashlytics singleton instance
275  *
276  *  @return Return NO if you don't want out-of-process background network operations.
277  *
278  */
279 - (BOOL)crashlyticsCanUseBackgroundSessions:(Crashlytics *)crashlytics;
280
281 @end
282
283 /**
284  *  `CrashlyticsKit` can be used as a parameter to `[Fabric with:@[CrashlyticsKit]];` in Objective-C. In Swift, use Crashlytics.sharedInstance()
285  */
286 #define CrashlyticsKit [Crashlytics sharedInstance]
287
288 NS_ASSUME_NONNULL_END