FBSDKConstants.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. /**
  11. The error domain for all errors from FBSDKCoreKit.
  12. Error codes from the SDK in the range 0-99 are reserved for this domain.
  13. */
  14. FOUNDATION_EXPORT NSErrorDomain const FBSDKErrorDomain
  15. NS_SWIFT_NAME(ErrorDomain);
  16. /*
  17. @methodgroup error userInfo keys
  18. */
  19. /**
  20. The userInfo key for the invalid collection for errors with FBSDKErrorInvalidArgument.
  21. If the invalid argument is a collection, the collection can be found with this key and the individual
  22. invalid item can be found with FBSDKErrorArgumentValueKey.
  23. */
  24. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentCollectionKey
  25. NS_SWIFT_NAME(ErrorArgumentCollectionKey);
  26. /// The userInfo key for the invalid argument name for errors with FBSDKErrorInvalidArgument.
  27. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentNameKey
  28. NS_SWIFT_NAME(ErrorArgumentNameKey);
  29. /// The userInfo key for the invalid argument value for errors with FBSDKErrorInvalidArgument.
  30. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentValueKey
  31. NS_SWIFT_NAME(ErrorArgumentValueKey);
  32. /**
  33. The userInfo key for the message for developers in NSErrors that originate from the SDK.
  34. The developer message will not be localized and is not intended to be presented within the app.
  35. */
  36. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorDeveloperMessageKey
  37. NS_SWIFT_NAME(ErrorDeveloperMessageKey);
  38. /// The userInfo key describing a localized description that can be presented to the user.
  39. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorLocalizedDescriptionKey
  40. NS_SWIFT_NAME(ErrorLocalizedDescriptionKey);
  41. /// The userInfo key describing a localized title that can be presented to the user, used with `FBSDKLocalizedErrorDescriptionKey`.
  42. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorLocalizedTitleKey
  43. NS_SWIFT_NAME(ErrorLocalizedTitleKey);
  44. /*
  45. @methodgroup FBSDKGraphRequest error userInfo keys
  46. */
  47. /**
  48. The userInfo key describing the error category, for error recovery purposes.
  49. See `FBSDKGraphErrorRecoveryProcessor` and `[FBSDKGraphRequest disableErrorRecovery]`.
  50. */
  51. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorKey
  52. NS_SWIFT_NAME(GraphRequestErrorKey);
  53. /*
  54. The userInfo key for the Graph API error code.
  55. */
  56. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorCodeKey
  57. NS_SWIFT_NAME(GraphRequestErrorGraphErrorCodeKey);
  58. /*
  59. The userInfo key for the Graph API error subcode.
  60. */
  61. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorSubcodeKey
  62. NS_SWIFT_NAME(GraphRequestErrorGraphErrorSubcodeKey);
  63. /*
  64. The userInfo key for the HTTP status code.
  65. */
  66. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorHTTPStatusCodeKey
  67. NS_SWIFT_NAME(GraphRequestErrorHTTPStatusCodeKey);
  68. /*
  69. The userInfo key for the raw JSON response.
  70. */
  71. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorParsedJSONResponseKey
  72. NS_SWIFT_NAME(GraphRequestErrorParsedJSONResponseKey);
  73. /*
  74. @methodgroup Common Code Block typedefs
  75. */
  76. /// Success Block
  77. typedef void (^ FBSDKCodeBlock)(void)
  78. NS_SWIFT_NAME(CodeBlock);
  79. /// Error Block
  80. typedef void (^ FBSDKErrorBlock)(NSError *_Nullable error)
  81. NS_SWIFT_NAME(ErrorBlock);
  82. /// Success Block
  83. typedef void (^ FBSDKSuccessBlock)(BOOL success, NSError *_Nullable error)
  84. NS_SWIFT_NAME(SuccessBlock);
  85. /*
  86. @methodgroup Enums
  87. */
  88. #ifndef NS_ERROR_ENUM
  89. #define NS_ERROR_ENUM(_domain, _name) \
  90. enum _name : NSInteger _name; \
  91. enum __attribute__((ns_error_domain(_domain))) _name: NSInteger
  92. #endif
  93. /**
  94. FBSDKCoreError
  95. Error codes for FBSDKErrorDomain.
  96. */
  97. typedef NS_ERROR_ENUM (FBSDKErrorDomain, FBSDKCoreError)
  98. {
  99. /// Reserved.
  100. FBSDKErrorReserved = 0,
  101. /// The error code for errors from invalid encryption on incoming encryption URLs.
  102. FBSDKErrorEncryption,
  103. /// The error code for errors from invalid arguments to SDK methods.
  104. FBSDKErrorInvalidArgument,
  105. /// The error code for unknown errors.
  106. FBSDKErrorUnknown,
  107. /**
  108. A request failed due to a network error. Use NSUnderlyingErrorKey to retrieve
  109. the error object from the NSURLSession for more information.
  110. */
  111. FBSDKErrorNetwork,
  112. /// The error code for errors encountered during an App Events flush.
  113. FBSDKErrorAppEventsFlush,
  114. /**
  115. An endpoint that returns a binary response was used with FBSDKGraphRequestConnection.
  116. Endpoints that return image/jpg, etc. should be accessed using NSURLRequest
  117. */
  118. FBSDKErrorGraphRequestNonTextMimeTypeReturned,
  119. /**
  120. The operation failed because the server returned an unexpected response.
  121. You can get this error if you are not using the most recent SDK, or you are accessing a version of the
  122. Graph API incompatible with the current SDK.
  123. */
  124. FBSDKErrorGraphRequestProtocolMismatch,
  125. /**
  126. The Graph API returned an error.
  127. See below for useful userInfo keys (beginning with FBSDKGraphRequestError*)
  128. */
  129. FBSDKErrorGraphRequestGraphAPI,
  130. /**
  131. The specified dialog configuration is not available.
  132. This error may signify that the configuration for the dialogs has not yet been downloaded from the server
  133. or that the dialog is unavailable. Subsequent attempts to use the dialog may succeed as the configuration is loaded.
  134. */
  135. FBSDKErrorDialogUnavailable,
  136. /// Indicates an operation failed because a required access token was not found.
  137. FBSDKErrorAccessTokenRequired,
  138. /// Indicates an app switch (typically for a dialog) failed because the destination app is out of date.
  139. FBSDKErrorAppVersionUnsupported,
  140. /// Indicates an app switch to the browser (typically for a dialog) failed.
  141. FBSDKErrorBrowserUnavailable,
  142. /// Indicates that a bridge api interaction was interrupted.
  143. FBSDKErrorBridgeAPIInterruption,
  144. /// Indicates that a bridge api response creation failed.
  145. FBSDKErrorBridgeAPIResponse,
  146. } NS_SWIFT_NAME(CoreError);
  147. /**
  148. FBSDKGraphRequestError
  149. Describes the category of Facebook error. See `FBSDKGraphRequestErrorKey`.
  150. */
  151. typedef NS_ENUM(NSUInteger, FBSDKGraphRequestError) {
  152. /// The default error category that is not known to be recoverable. Check `FBSDKLocalizedErrorDescriptionKey` for a user facing message.
  153. FBSDKGraphRequestErrorOther = 0,
  154. /// Indicates the error is temporary (such as server throttling). While a recoveryAttempter will be provided with the error instance, the attempt is guaranteed to succeed so you can simply retry the operation if you do not want to present an alert.
  155. FBSDKGraphRequestErrorTransient = 1,
  156. /// Indicates the error can be recovered (such as requiring a login). A recoveryAttempter will be provided with the error instance that can take UI action.
  157. FBSDKGraphRequestErrorRecoverable = 2,
  158. } NS_SWIFT_NAME(GraphRequestError);
  159. /**
  160. Internal value exposed to facilitate transition to Swift.
  161. API Subject to change or removal without warning. Do not use.
  162. @warning INTERNAL - DO NOT USE
  163. */
  164. FOUNDATION_EXPORT NSString *const DefaultKeychainServicePrefix;
  165. NS_ASSUME_NONNULL_END