FBSDKConstants.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. // Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  2. //
  3. // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  4. // copy, modify, and distribute this software in source code or binary form for use
  5. // in connection with the web services and APIs provided by Facebook.
  6. //
  7. // As with any software that integrates with the Facebook platform, your use of
  8. // this software is subject to the Facebook Developer Principles and Policies
  9. // [http://developers.facebook.com/policy/]. This copyright notice shall be
  10. // included in all copies or substantial portions of the software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. #import <Foundation/Foundation.h>
  19. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
  20. /**
  21. The error domain for all errors from FBSDKCoreKit.
  22. Error codes from the SDK in the range 0-99 are reserved for this domain.
  23. */
  24. FOUNDATION_EXPORT NSErrorDomain const FBSDKErrorDomain;
  25. #else
  26. /**
  27. The error domain for all errors from FBSDKCoreKit.
  28. Error codes from the SDK in the range 0-99 are reserved for this domain.
  29. */
  30. FOUNDATION_EXPORT NSString *const FBSDKErrorDomain;
  31. #endif
  32. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0
  33. /*
  34. @methodgroup error userInfo keys
  35. */
  36. /**
  37. The userInfo key for the invalid collection for errors with FBSDKErrorInvalidArgument.
  38. If the invalid argument is a collection, the collection can be found with this key and the individual
  39. invalid item can be found with FBSDKErrorArgumentValueKey.
  40. */
  41. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentCollectionKey;
  42. /**
  43. The userInfo key for the invalid argument name for errors with FBSDKErrorInvalidArgument.
  44. */
  45. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentNameKey;
  46. /**
  47. The userInfo key for the invalid argument value for errors with FBSDKErrorInvalidArgument.
  48. */
  49. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorArgumentValueKey;
  50. /**
  51. The userInfo key for the message for developers in NSErrors that originate from the SDK.
  52. The developer message will not be localized and is not intended to be presented within the app.
  53. */
  54. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorDeveloperMessageKey;
  55. /**
  56. The userInfo key describing a localized description that can be presented to the user.
  57. */
  58. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorLocalizedDescriptionKey;
  59. /**
  60. The userInfo key describing a localized title that can be presented to the user, used with `FBSDKLocalizedErrorDescriptionKey`.
  61. */
  62. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKErrorLocalizedTitleKey;
  63. /*
  64. @methodgroup FBSDKGraphRequest error userInfo keys
  65. */
  66. /**
  67. The userInfo key describing the error category, for error recovery purposes.
  68. See `FBSDKGraphErrorRecoveryProcessor` and `[FBSDKGraphRequest disableErrorRecovery]`.
  69. */
  70. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorKey;
  71. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorCategoryKey
  72. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorKey instead");
  73. /*
  74. The userInfo key for the Graph API error code.
  75. */
  76. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorCodeKey;
  77. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorCode
  78. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorGraphErrorCodeKey instead");
  79. /*
  80. The userInfo key for the Graph API error subcode.
  81. */
  82. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorSubcodeKey;
  83. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorGraphErrorSubcode
  84. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorGraphErrorSubcodeKey instead");
  85. /*
  86. The userInfo key for the HTTP status code.
  87. */
  88. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorHTTPStatusCodeKey;
  89. /*
  90. The userInfo key for the raw JSON response.
  91. */
  92. FOUNDATION_EXPORT NSErrorUserInfoKey const FBSDKGraphRequestErrorParsedJSONResponseKey;
  93. #else
  94. /*
  95. @methodgroup error userInfo keys
  96. */
  97. /**
  98. The userInfo key for the invalid collection for errors with FBSDKErrorInvalidArgument.
  99. If the invalid argument is a collection, the collection can be found with this key and the individual
  100. invalid item can be found with FBSDKErrorArgumentValueKey.
  101. */
  102. FOUNDATION_EXPORT NSString *const FBSDKErrorArgumentCollectionKey;
  103. /**
  104. The userInfo key for the invalid argument name for errors with FBSDKErrorInvalidArgument.
  105. */
  106. FOUNDATION_EXPORT NSString *const FBSDKErrorArgumentNameKey;
  107. /**
  108. The userInfo key for the invalid argument value for errors with FBSDKErrorInvalidArgument.
  109. */
  110. FOUNDATION_EXPORT NSString *const FBSDKErrorArgumentValueKey;
  111. /**
  112. The userInfo key for the message for developers in NSErrors that originate from the SDK.
  113. The developer message will not be localized and is not intended to be presented within the app.
  114. */
  115. FOUNDATION_EXPORT NSString *const FBSDKErrorDeveloperMessageKey;
  116. /**
  117. The userInfo key describing a localized description that can be presented to the user.
  118. */
  119. FOUNDATION_EXPORT NSString *const FBSDKErrorLocalizedDescriptionKey;
  120. /**
  121. The userInfo key describing a localized title that can be presented to the user, used with `FBSDKLocalizedErrorDescriptionKey`.
  122. */
  123. FOUNDATION_EXPORT NSString *const FBSDKErrorLocalizedTitleKey;
  124. /*
  125. @methodgroup FBSDKGraphRequest error userInfo keys
  126. */
  127. /**
  128. The userInfo key describing the error category, for error recovery purposes.
  129. See `FBSDKGraphErrorRecoveryProcessor` and `[FBSDKGraphRequest disableErrorRecovery]`.
  130. */
  131. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorKey;
  132. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorCategoryKey
  133. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorKey instead");
  134. /*
  135. The userInfo key for the Graph API error code.
  136. */
  137. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorGraphErrorCodeKey;
  138. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorGraphErrorCode
  139. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorGraphErrorCodeKey instead");
  140. /*
  141. The userInfo key for the Graph API error subcode.
  142. */
  143. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorGraphErrorSubcodeKey;
  144. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorGraphErrorSubcode
  145. DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorGraphErrorSubcodeKey instead");
  146. /*
  147. The userInfo key for the HTTP status code.
  148. */
  149. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorHTTPStatusCodeKey;
  150. /*
  151. The userInfo key for the raw JSON response.
  152. */
  153. FOUNDATION_EXPORT NSString *const FBSDKGraphRequestErrorParsedJSONResponseKey;
  154. #endif
  155. #ifndef NS_ERROR_ENUM
  156. #define NS_ERROR_ENUM(_domain, _name) \
  157. enum _name: NSInteger _name; \
  158. enum __attribute__((ns_error_domain(_domain))) _name: NSInteger
  159. #endif
  160. /**
  161. FBSDKError
  162. Error codes for FBSDKErrorDomain.
  163. */
  164. typedef NS_ERROR_ENUM(FBSDKErrorDomain, FBSDKError)
  165. {
  166. /**
  167. Reserved.
  168. */
  169. FBSDKErrorReserved = 0,
  170. /**
  171. The error code for errors from invalid encryption on incoming encryption URLs.
  172. */
  173. FBSDKErrorEncryption,
  174. /**
  175. The error code for errors from invalid arguments to SDK methods.
  176. */
  177. FBSDKErrorInvalidArgument,
  178. /**
  179. The error code for unknown errors.
  180. */
  181. FBSDKErrorUnknown,
  182. /**
  183. A request failed due to a network error. Use NSUnderlyingErrorKey to retrieve
  184. the error object from the NSURLSession for more information.
  185. */
  186. FBSDKErrorNetwork,
  187. /**
  188. The error code for errors encountered during an App Events flush.
  189. */
  190. FBSDKErrorAppEventsFlush,
  191. /**
  192. An endpoint that returns a binary response was used with FBSDKGraphRequestConnection.
  193. Endpoints that return image/jpg, etc. should be accessed using NSURLRequest
  194. */
  195. FBSDKErrorGraphRequestNonTextMimeTypeReturned,
  196. /**
  197. The operation failed because the server returned an unexpected response.
  198. You can get this error if you are not using the most recent SDK, or you are accessing a version of the
  199. Graph API incompatible with the current SDK.
  200. */
  201. FBSDKErrorGraphRequestProtocolMismatch,
  202. /**
  203. The Graph API returned an error.
  204. See below for useful userInfo keys (beginning with FBSDKGraphRequestError*)
  205. */
  206. FBSDKErrorGraphRequestGraphAPI,
  207. /**
  208. The specified dialog configuration is not available.
  209. This error may signify that the configuration for the dialogs has not yet been downloaded from the server
  210. or that the dialog is unavailable. Subsequent attempts to use the dialog may succeed as the configuration is loaded.
  211. */
  212. FBSDKErrorDialogUnavailable,
  213. /**
  214. Indicates an operation failed because a required access token was not found.
  215. */
  216. FBSDKErrorAccessTokenRequired,
  217. /**
  218. Indicates an app switch (typically for a dialog) failed because the destination app is out of date.
  219. */
  220. FBSDKErrorAppVersionUnsupported,
  221. /**
  222. Indicates an app switch to the browser (typically for a dialog) failed.
  223. */
  224. FBSDKErrorBrowserUnavailable,
  225. };
  226. /**
  227. FBSDKGraphRequestError
  228. Describes the category of Facebook error. See `FBSDKGraphRequestErrorKey`.
  229. */
  230. typedef NS_ENUM(NSUInteger, FBSDKGraphRequestError)
  231. {
  232. /** The default error category that is not known to be recoverable. Check `FBSDKLocalizedErrorDescriptionKey` for a user facing message. */
  233. FBSDKGraphRequestErrorOther = 0,
  234. /** 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. */
  235. FBSDKGraphRequestErrorTransient = 1,
  236. /** 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. */
  237. FBSDKGraphRequestErrorRecoverable = 2
  238. };
  239. /**
  240. a formal protocol very similar to the informal protocol NSErrorRecoveryAttempting
  241. */
  242. @protocol FBSDKErrorRecoveryAttempting<NSObject>
  243. /**
  244. attempt the recovery
  245. @param error the error
  246. @param recoveryOptionIndex the selected option index
  247. @param delegate the delegate
  248. @param didRecoverSelector the callback selector, see discussion.
  249. @param contextInfo context info to pass back to callback selector, see discussion.
  250. Given that an error alert has been presented document-modally to the user, and the user has chosen one of the error's recovery options, attempt recovery from the error, and send the selected message to the specified delegate. The option index is an index into the error's array of localized recovery options. The method selected by didRecoverSelector must have the same signature as:
  251. - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo;
  252. The value passed for didRecover must be YES if error recovery was completely successful, NO otherwise.
  253. */
  254. - (void)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex delegate:(id)delegate didRecoverSelector:(SEL)didRecoverSelector contextInfo:(void *)contextInfo;
  255. @end
  256. /**
  257. Deprecated
  258. */
  259. typedef NS_ENUM(NSInteger, FBSDKErrorCode)
  260. {
  261. FBSDKReservedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorReserved instead") = 0,
  262. FBSDKEncryptionErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorEncryption instead"),
  263. FBSDKInvalidArgumentErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorInvalidArgument instead"),
  264. FBSDKUnknownErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorUnknown instead"),
  265. FBSDKNetworkErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorNetwork instead"),
  266. FBSDKAppEventsFlushErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorAppEventsFlush instead"),
  267. FBSDKGraphRequestNonTextMimeTypeReturnedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorGraphRequestNonTextMimeTypeReturned instead"),
  268. FBSDKGraphRequestProtocolMismatchErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorGraphRequestProtocolMismatch instead"),
  269. FBSDKGraphRequestGraphAPIErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorGraphRequestGraphAPI instead"),
  270. FBSDKDialogUnavailableErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorDialogUnavailable instead"),
  271. FBSDKAccessTokenRequiredErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorAccessTokenRequired instead"),
  272. FBSDKAppVersionUnsupportedErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorAppVersionUnsupported instead"),
  273. FBSDKBrowserUnavailableErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorBrowserUnavailable instead"),
  274. FBSDKBrowswerUnavailableErrorCode DEPRECATED_MSG_ATTRIBUTE("use FBSDKErrorBrowserUnavailable instead") = FBSDKBrowserUnavailableErrorCode,
  275. } DEPRECATED_MSG_ATTRIBUTE("use FBSDKError instead");
  276. /**
  277. Deprecated
  278. */
  279. typedef NS_ENUM(NSUInteger, FBSDKGraphRequestErrorCategory)
  280. {
  281. FBSDKGraphRequestErrorCategoryOther DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorOther instead") = 0,
  282. FBSDKGraphRequestErrorCategoryTransient DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorTransient instead") = 1,
  283. FBSDKGraphRequestErrorCategoryRecoverable DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestErrorRecoverable instead") = 2
  284. } DEPRECATED_MSG_ATTRIBUTE("use FBSDKGraphRequestError instead");