PageRenderTime 30ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Crashlytics.framework/Headers/Crashlytics.h

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