FBSDKAppInviteDialog.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 <UIKit/UIKit.h>
  20. #import <FBSDKShareKit/FBSDKAppInviteContent.h>
  21. @protocol FBSDKAppInviteDialogDelegate;
  22. /*!
  23. @abstract A dialog for sending App Invites.
  24. */
  25. @interface FBSDKAppInviteDialog : NSObject
  26. /*!
  27. @abstract Convenience method to show a FBSDKAppInviteDialog
  28. @param viewController A UIViewController to present the dialog from.
  29. @param content The content for the app invite.
  30. @param delegate The receiver's delegate.
  31. */
  32. + (instancetype)showFromViewController:(UIViewController *)viewController
  33. withContent:(FBSDKAppInviteContent *)content
  34. delegate:(id<FBSDKAppInviteDialogDelegate>)delegate;
  35. /*!
  36. @deprecated use showFromViewController:withContent:delegate: instead
  37. */
  38. + (instancetype)showWithContent:(FBSDKAppInviteContent *)content delegate:(id<FBSDKAppInviteDialogDelegate>)delegate
  39. __attribute__ ((deprecated("use showFromViewController:withContent:delegate: instead")));
  40. /*!
  41. @abstract A UIViewController to present the dialog from.
  42. @discussion If not specified, the top most view controller will be automatically determined as best as possible.
  43. */
  44. @property (nonatomic, weak) UIViewController *fromViewController;
  45. /*!
  46. @abstract The receiver's delegate or nil if it doesn't have a delegate.
  47. */
  48. @property (nonatomic, weak) id<FBSDKAppInviteDialogDelegate> delegate;
  49. /*!
  50. @abstract The content for app invite.
  51. */
  52. @property (nonatomic, copy) FBSDKAppInviteContent *content;
  53. /*!
  54. @abstract A Boolean value that indicates whether the receiver can initiate an app invite.
  55. @discussion May return NO if the appropriate Facebook app is not installed and is required or an access token is
  56. required but not available. This method does not validate the content on the receiver, so this can be checked before
  57. building up the content.
  58. @see validateWithError:
  59. @result YES if the receiver can show the dialog, otherwise NO.
  60. */
  61. - (BOOL)canShow;
  62. /*!
  63. @abstract Begins the app invite from the receiver.
  64. @result YES if the receiver was able to show the dialog, otherwise NO.
  65. */
  66. - (BOOL)show;
  67. /*!
  68. @abstract Validates the content on the receiver.
  69. @param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
  70. @return YES if the content is valid, otherwise NO.
  71. */
  72. - (BOOL)validateWithError:(NSError *__autoreleasing *)errorRef;
  73. @end
  74. /*!
  75. @abstract A delegate for FBSDKAppInviteDialog.
  76. @discussion The delegate is notified with the results of the app invite as long as the application has permissions to
  77. receive the information. For example, if the person is not signed into the containing app, the shower may not be able
  78. to distinguish between completion of an app invite and cancellation.
  79. */
  80. @protocol FBSDKAppInviteDialogDelegate <NSObject>
  81. /*!
  82. @abstract Sent to the delegate when the app invite completes without error.
  83. @param appInviteDialog The FBSDKAppInviteDialog that completed.
  84. @param results The results from the dialog. This may be nil or empty.
  85. */
  86. - (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didCompleteWithResults:(NSDictionary *)results;
  87. /*!
  88. @abstract Sent to the delegate when the app invite encounters an error.
  89. @param appInviteDialog The FBSDKAppInviteDialog that completed.
  90. @param error The error.
  91. */
  92. - (void)appInviteDialog:(FBSDKAppInviteDialog *)appInviteDialog didFailWithError:(NSError *)error;
  93. @end