FBSDKLoginButton.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 <UIKit/UIKit.h>
  19. #import <FBSDKCoreKit/FBSDKButton.h>
  20. #import <FBSDKLoginKit/FBSDKLoginManager.h>
  21. #import "FBSDKTooltipView.h"
  22. @protocol FBSDKLoginButtonDelegate;
  23. /**
  24. NS_ENUM(NSUInteger, FBSDKLoginButtonTooltipBehavior)
  25. Indicates the desired login tooltip behavior.
  26. */
  27. typedef NS_ENUM(NSUInteger, FBSDKLoginButtonTooltipBehavior)
  28. {
  29. /** The default behavior. The tooltip will only be displayed if
  30. the app is eligible (determined by possible server round trip) */
  31. FBSDKLoginButtonTooltipBehaviorAutomatic = 0,
  32. /** Force display of the tooltip (typically for UI testing) */
  33. FBSDKLoginButtonTooltipBehaviorForceDisplay = 1,
  34. /** Force disable. In this case you can still exert more refined
  35. control by manually constructing a `FBSDKLoginTooltipView` instance. */
  36. FBSDKLoginButtonTooltipBehaviorDisable = 2
  37. };
  38. /**
  39. A button that initiates a log in or log out flow upon tapping.
  40. `FBSDKLoginButton` works with `[FBSDKAccessToken currentAccessToken]` to
  41. determine what to display, and automatically starts authentication when tapped (i.e.,
  42. you do not need to manually subscribe action targets).
  43. Like `FBSDKLoginManager`, you should make sure your app delegate is connected to
  44. `FBSDKApplicationDelegate` in order for the button's delegate to receive messages.
  45. `FBSDKLoginButton` has a fixed height of @c 30 pixels, but you may change the width. `initWithFrame:CGRectZero`
  46. will size the button to its minimum frame.
  47. */
  48. @interface FBSDKLoginButton : FBSDKButton
  49. /**
  50. The default audience to use, if publish permissions are requested at login time.
  51. */
  52. @property (assign, nonatomic) FBSDKDefaultAudience defaultAudience;
  53. /**
  54. Gets or sets the delegate.
  55. */
  56. @property (weak, nonatomic) IBOutlet id<FBSDKLoginButtonDelegate> delegate;
  57. /**
  58. Gets or sets the login behavior to use
  59. */
  60. @property (assign, nonatomic) FBSDKLoginBehavior loginBehavior;
  61. /**
  62. The publish permissions to request.
  63. Use `defaultAudience` to specify the default audience to publish to.
  64. Note this is converted to NSSet and is only
  65. an NSArray for the convenience of literal syntax.
  66. */
  67. @property (copy, nonatomic) NSArray *publishPermissions;
  68. /**
  69. The read permissions to request.
  70. Note, that if read permissions are specified, then publish permissions should not be specified. This is converted to NSSet and is only
  71. an NSArray for the convenience of literal syntax.
  72. */
  73. @property (copy, nonatomic) NSArray *readPermissions;
  74. /**
  75. Gets or sets the desired tooltip behavior.
  76. */
  77. @property (assign, nonatomic) FBSDKLoginButtonTooltipBehavior tooltipBehavior;
  78. /**
  79. Gets or sets the desired tooltip color style.
  80. */
  81. @property (assign, nonatomic) FBSDKTooltipColorStyle tooltipColorStyle;
  82. @end
  83. /**
  84. @protocol
  85. A delegate for `FBSDKLoginButton`
  86. */
  87. @protocol FBSDKLoginButtonDelegate <NSObject>
  88. @required
  89. /**
  90. Sent to the delegate when the button was used to login.
  91. @param loginButton the sender
  92. @param result The results of the login
  93. @param error The error (if any) from the login
  94. */
  95. - (void)loginButton:(FBSDKLoginButton *)loginButton
  96. didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
  97. error:(NSError *)error;
  98. /**
  99. Sent to the delegate when the button was used to logout.
  100. @param loginButton The button that was clicked.
  101. */
  102. - (void)loginButtonDidLogOut:(FBSDKLoginButton *)loginButton;
  103. @optional
  104. /**
  105. Sent to the delegate when the button is about to login.
  106. @param loginButton the sender
  107. @return YES if the login should be allowed to proceed, NO otherwise
  108. */
  109. - (BOOL) loginButtonWillLogin:(FBSDKLoginButton *)loginButton;
  110. @end