FBSDKShareAPI.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #import <FBSDKCoreKit/FBSDKAccessToken.h>
  20. #import <FBSDKShareKit/FBSDKShareOpenGraphObject.h>
  21. #import <FBSDKShareKit/FBSDKSharing.h>
  22. /*!
  23. @abstract A utility class for sharing through the graph API. Using this class requires an access token that
  24. has been granted the "publish_actions" permission.
  25. @discussion FBSDKShareAPI network requests are scheduled on the current run loop in the default run loop mode
  26. (like NSURLConnection). If you want to use FBSDKShareAPI in a background thread, you must manage the run loop
  27. yourself.
  28. */
  29. @interface FBSDKShareAPI : NSObject <FBSDKSharing>
  30. /*!
  31. @abstract Convenience method to build up a share API with content and a delegate.
  32. @param content The content to be shared.
  33. @param delegate The receiver's delegate.
  34. */
  35. + (instancetype)shareWithContent:(id<FBSDKSharingContent>)content delegate:(id<FBSDKSharingDelegate>)delegate;
  36. /*!
  37. @abstract The message the person has provided through the custom dialog that will accompany the share content.
  38. */
  39. @property (nonatomic, copy) NSString *message;
  40. /*!
  41. @abstract The graph node to which content should be shared.
  42. */
  43. @property (nonatomic, copy) NSString *graphNode;
  44. /*!
  45. @abstract The access token used when performing a share. The access token must have the "publish_actions"
  46. permission granted.
  47. @discussion Defaults to [FBSDKAccessToken currentAccessToken]. Setting this to nil will revert the access token to
  48. [FBSDKAccessToken currentAccessToken].
  49. */
  50. @property (nonatomic, strong) FBSDKAccessToken *accessToken;
  51. /*!
  52. @abstract A Boolean value that indicates whether the receiver can send the share.
  53. @discussion May return NO if the appropriate Facebook app is not installed and is required or an access token is
  54. required but not available. This method does not validate the content on the receiver, so this can be checked before
  55. building up the content.
  56. @see [FBSDKSharing validateWithError:]
  57. @result YES if the receiver can send, otherwise NO.
  58. */
  59. - (BOOL)canShare;
  60. /*!
  61. @abstract Creates an User Owned Open Graph object without an action.
  62. @param openGraphObject The open graph object to create.
  63. @discussion Use this method to create an object alone, when an action is not going to be posted with the object. If
  64. the object will be used within an action, just put the object in the action and share that as the shareContent and the
  65. object will be created in the process. The delegate will be messaged with the results.
  66. Also see https://developers.facebook.com/docs/sharing/opengraph/object-api#objectapi-creatinguser
  67. @result YES if the receiver was able to send the request to create the object, otherwise NO.
  68. */
  69. - (BOOL)createOpenGraphObject:(FBSDKShareOpenGraphObject *)openGraphObject;
  70. /*!
  71. @abstract Begins the send from the receiver.
  72. @result YES if the receiver was able to send the share, otherwise NO.
  73. */
  74. - (BOOL)share;
  75. @end