FBSDKDeviceLoginManager.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <FBSDKLoginKit/FBSDKDeviceLoginCodeInfo.h>
  20. #import <FBSDKLoginKit/FBSDKDeviceLoginManagerResult.h>
  21. NS_ASSUME_NONNULL_BEGIN
  22. @class FBSDKDeviceLoginManager;
  23. /*!
  24. @abstract A delegate for `FBSDKDeviceLoginManager`.
  25. */
  26. @protocol FBSDKDeviceLoginManagerDelegate <NSObject>
  27. /*!
  28. @abstract Indicates the device login flow has started. You should parse `codeInfo` to
  29. present the code to the user to enter.
  30. @param loginManager the login manager instance.
  31. @param codeInfo the code info data.
  32. */
  33. - (void)deviceLoginManager:(FBSDKDeviceLoginManager *)loginManager startedWithCodeInfo:(FBSDKDeviceLoginCodeInfo *)codeInfo;
  34. /*!
  35. @abstract Indicates the device login flow has finished.
  36. @param loginManager the login manager instance.
  37. @param result the results of the login flow.
  38. @param error the error, if available.
  39. @discussion The flow can be finished if the user completed the flow, cancelled, or if the code has expired.
  40. */
  41. - (void)deviceLoginManager:(FBSDKDeviceLoginManager *)loginManager
  42. completedWithResult:(nullable FBSDKDeviceLoginManagerResult *)result
  43. error:(nullable NSError *)error;
  44. @end
  45. /*!
  46. @abstract Use this class to perform a device login flow.
  47. @discussion The device login flow starts by requesting a code from the device login API.
  48. This class informs the delegate when this code is received. You should then present the
  49. code to the user to enter. In the meantime, this class polls the device login API
  50. periodically and informs the delegate of the results.
  51. See [Facebook Device Login](https://developers.facebook.com/docs/facebook-login/for-devices).
  52. */
  53. @interface FBSDKDeviceLoginManager : NSObject <NSNetServiceDelegate>
  54. /*!
  55. @abstract Initializes a new instance.
  56. @param permissions permissions to request.
  57. */
  58. - (instancetype)initWithPermissions:(nullable NSArray<NSString *> *)permissions
  59. enableSmartLogin:(BOOL)enableSmartLogin
  60. NS_DESIGNATED_INITIALIZER;
  61. - (instancetype)init NS_UNAVAILABLE;
  62. + (instancetype)new NS_UNAVAILABLE;
  63. /*!
  64. @abstract the delegate.
  65. */
  66. @property (nonatomic, weak) id<FBSDKDeviceLoginManagerDelegate> delegate;
  67. /*!
  68. @abstract the requested permissions.
  69. */
  70. @property (nullable, nonatomic, copy, readonly) NSArray<NSString *> *permissions;
  71. /*!
  72. @abstract the optional URL to redirect the user to after they complete the login.
  73. @discussion the URL must be configured in your App Settings -> Advanced -> OAuth Redirect URIs
  74. */
  75. @property (nullable, nonatomic, copy) NSURL *redirectURL;
  76. /*!
  77. @abstract Starts the device login flow
  78. @discussion This instance will retain self until the flow is finished or cancelled.
  79. */
  80. - (void)start;
  81. /*!
  82. @abstract Attempts to cancel the device login flow.
  83. */
  84. - (void)cancel;
  85. @end
  86. NS_ASSUME_NONNULL_END