FBSDKGraphRequestConnectionDelegate.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #import <FBSDKCoreKit/FBSDKGraphRequestConnecting.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. /**
  12. @protocol
  13. The `FBSDKGraphRequestConnectionDelegate` protocol defines the methods used to receive network
  14. activity progress information from a <FBSDKGraphRequestConnection>.
  15. */
  16. NS_SWIFT_NAME(GraphRequestConnectionDelegate)
  17. @protocol FBSDKGraphRequestConnectionDelegate <NSObject>
  18. @optional
  19. /**
  20. @method
  21. Tells the delegate the request connection will begin loading
  22. If the <FBSDKGraphRequestConnection> is created using one of the convenience factory methods prefixed with
  23. start, the object returned from the convenience method has already begun loading and this method
  24. will not be called when the delegate is set.
  25. @param connection The request connection that is starting a network request
  26. */
  27. - (void)requestConnectionWillBeginLoading:(id<FBSDKGraphRequestConnecting>)connection;
  28. /**
  29. @method
  30. Tells the delegate the request connection finished loading
  31. If the request connection completes without a network error occurring then this method is called.
  32. Invocation of this method does not indicate success of every <FBSDKGraphRequest> made, only that the
  33. request connection has no further activity. Use the error argument passed to the FBSDKGraphRequestBlock
  34. block to determine success or failure of each <FBSDKGraphRequest>.
  35. This method is invoked after the completion handler for each <FBSDKGraphRequest>.
  36. @param connection The request connection that successfully completed a network request
  37. */
  38. - (void)requestConnectionDidFinishLoading:(id<FBSDKGraphRequestConnecting>)connection;
  39. /**
  40. @method
  41. Tells the delegate the request connection failed with an error
  42. If the request connection fails with a network error then this method is called. The `error`
  43. argument specifies why the network connection failed. The `NSError` object passed to the
  44. FBSDKGraphRequestBlock block may contain additional information.
  45. @param connection The request connection that successfully completed a network request
  46. @param error The `NSError` representing the network error that occurred, if any. May be nil
  47. in some circumstances. Consult the `NSError` for the <FBSDKGraphRequest> for reliable
  48. failure information.
  49. */
  50. - (void)requestConnection:(id<FBSDKGraphRequestConnecting>)connection
  51. didFailWithError:(NSError *)error;
  52. /**
  53. @method
  54. Tells the delegate how much data has been sent and is planned to send to the remote host
  55. The byte count arguments refer to the aggregated <FBSDKGraphRequest> objects, not a particular <FBSDKGraphRequest>.
  56. Like `NSURLSession`, the values may change in unexpected ways if data needs to be resent.
  57. @param connection The request connection transmitting data to a remote host
  58. @param bytesWritten The number of bytes sent in the last transmission
  59. @param totalBytesWritten The total number of bytes sent to the remote host
  60. @param totalBytesExpectedToWrite The total number of bytes expected to send to the remote host
  61. */
  62. - (void) requestConnection:(id<FBSDKGraphRequestConnecting>)connection
  63. didSendBodyData:(NSInteger)bytesWritten
  64. totalBytesWritten:(NSInteger)totalBytesWritten
  65. totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
  66. @end
  67. NS_ASSUME_NONNULL_END