commit | author | age
|
bad748
|
1 |
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved. |
W |
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 |
|
|
19 |
#import <Foundation/Foundation.h> |
|
20 |
#import <UIKit/UIKit.h> |
|
21 |
|
e81c27
|
22 |
NS_ASSUME_NONNULL_BEGIN |
H |
23 |
|
bad748
|
24 |
@class FBSDKLoginManagerLoginResult; |
e81c27
|
25 |
|
H |
26 |
/// typedef for FBSDKLoginAuthType |
|
27 |
typedef NSString *const FBSDKLoginAuthType NS_TYPED_EXTENSIBLE_ENUM NS_SWIFT_NAME(LoginAuthType); |
|
28 |
|
|
29 |
/// Rerequest |
|
30 |
FOUNDATION_EXPORT FBSDKLoginAuthType FBSDKLoginAuthTypeRerequest; |
|
31 |
|
|
32 |
/// Reauthorize |
|
33 |
FOUNDATION_EXPORT FBSDKLoginAuthType FBSDKLoginAuthTypeReauthorize; |
bad748
|
34 |
|
9febd9
|
35 |
/** |
W |
36 |
Describes the call back to the FBSDKLoginManager |
13e53a
|
37 |
@param result the result of the authorization |
H |
38 |
@param error the authorization error, if any. |
bad748
|
39 |
*/ |
e81c27
|
40 |
typedef void (^FBSDKLoginManagerLoginResultBlock)(FBSDKLoginManagerLoginResult *_Nullable result, |
H |
41 |
NSError *_Nullable error) |
|
42 |
NS_SWIFT_NAME(LoginManagerLoginResultBlock); |
bad748
|
43 |
|
W |
44 |
|
9febd9
|
45 |
/** |
W |
46 |
FBSDKDefaultAudience enum |
bad748
|
47 |
|
9febd9
|
48 |
Passed to open to indicate which default audience to use for sessions that post data to Facebook. |
bad748
|
49 |
|
9febd9
|
50 |
|
W |
51 |
|
bad748
|
52 |
Certain operations such as publishing a status or publishing a photo require an audience. When the user |
W |
53 |
grants an application permission to perform a publish operation, a default audience is selected as the |
|
54 |
publication ceiling for the application. This enumerated value allows the application to select which |
|
55 |
audience to ask the user to grant publish permission for. |
|
56 |
*/ |
|
57 |
typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience) |
|
58 |
{ |
9febd9
|
59 |
/** Indicates that the user's friends are able to see posts made by the application */ |
bad748
|
60 |
FBSDKDefaultAudienceFriends = 0, |
9febd9
|
61 |
/** Indicates that only the user is able to see posts made by the application */ |
bad748
|
62 |
FBSDKDefaultAudienceOnlyMe, |
9febd9
|
63 |
/** Indicates that all Facebook users are able to see posts made by the application */ |
bad748
|
64 |
FBSDKDefaultAudienceEveryone, |
e81c27
|
65 |
} NS_SWIFT_NAME(DefaultAudience); |
bad748
|
66 |
|
9febd9
|
67 |
/** |
W |
68 |
FBSDKLoginBehavior enum |
bad748
|
69 |
|
9febd9
|
70 |
Passed to the \c FBSDKLoginManager to indicate how Facebook Login should be attempted. |
bad748
|
71 |
|
9febd9
|
72 |
|
W |
73 |
|
bad748
|
74 |
Facebook Login authorizes the application to act on behalf of the user, using the user's |
W |
75 |
Facebook account. Usually a Facebook Login will rely on an account maintained outside of |
|
76 |
the application, by the native Facebook application, the browser, or perhaps the device |
|
77 |
itself. This avoids the need for a user to enter their username and password directly, and |
|
78 |
provides the most secure and lowest friction way for a user to authorize the application to |
|
79 |
interact with Facebook. |
|
80 |
|
|
81 |
The \c FBSDKLoginBehavior enum specifies which log-in methods may be used. The SDK |
|
82 |
will determine the best behavior based on the current device (such as iOS version). |
|
83 |
*/ |
|
84 |
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) |
|
85 |
{ |
9febd9
|
86 |
/** |
e81c27
|
87 |
This is the default behavior, and indicates logging in via ASWebAuthenticationSession (iOS 12+) or SFAuthenticationSession (iOS 11), |
H |
88 |
which present specialized SafariViewControllers. Falls back to plain SFSafariViewController (iOS 9 and 10) or Safari (iOS 8). |
bad748
|
89 |
*/ |
e81c27
|
90 |
FBSDKLoginBehaviorBrowser = 0, |
88188e
|
91 |
} NS_SWIFT_NAME(LoginBehavior) |
L |
92 |
DEPRECATED_MSG_ATTRIBUTE("All login flows utilize the browser. This will be removed in the next major release"); |
bad748
|
93 |
|
9febd9
|
94 |
/** |
W |
95 |
`FBSDKLoginManager` provides methods for logging the user in and out. |
|
96 |
|
|
97 |
`FBSDKLoginManager` works directly with `[FBSDKAccessToken currentAccessToken]` and |
bad748
|
98 |
sets the "currentAccessToken" upon successful authorizations (or sets `nil` in case of `logOut`). |
W |
99 |
|
|
100 |
You should check `[FBSDKAccessToken currentAccessToken]` before calling logIn* to see if there is |
|
101 |
a cached token available (typically in your viewDidLoad). |
|
102 |
|
|
103 |
If you are managing your own token instances outside of "currentAccessToken", you will need to set |
9febd9
|
104 |
"currentAccessToken" before calling logIn* to authorize further permissions on your tokens. |
bad748
|
105 |
*/ |
e81c27
|
106 |
NS_SWIFT_NAME(LoginManager) |
bad748
|
107 |
@interface FBSDKLoginManager : NSObject |
W |
108 |
|
9febd9
|
109 |
/** |
9f077b
|
110 |
Auth type |
H |
111 |
*/ |
e81c27
|
112 |
@property (strong, nonatomic) FBSDKLoginAuthType authType; |
9f077b
|
113 |
/** |
9febd9
|
114 |
the default audience. |
W |
115 |
|
|
116 |
you should set this if you intend to ask for publish permissions. |
bad748
|
117 |
*/ |
W |
118 |
@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience; |
|
119 |
|
9febd9
|
120 |
/** |
W |
121 |
the login behavior |
bad748
|
122 |
*/ |
88188e
|
123 |
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior |
L |
124 |
DEPRECATED_MSG_ATTRIBUTE("All login flows utilize the browser. This will be removed in the next major release"); |
bad748
|
125 |
|
9febd9
|
126 |
/** |
e81c27
|
127 |
Logs the user in or authorizes additional permissions. |
13e53a
|
128 |
@param permissions the optional array of permissions. Note this is converted to NSSet and is only |
bad748
|
129 |
an NSArray for the convenience of literal syntax. |
13e53a
|
130 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
bad748
|
131 |
automatically determined as best as possible. |
13e53a
|
132 |
@param handler the callback. |
9febd9
|
133 |
|
e81c27
|
134 |
Use this method when asking for read permissions. You should only ask for permissions when they |
bad748
|
135 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
W |
136 |
provide more information to the user if they decline permissions. |
|
137 |
|
|
138 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
139 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
140 |
you could make that check at viewDidLoad. |
9febd9
|
141 |
You can only do one login call at a time. Calling a login method before the completion handler is called |
W |
142 |
on a previous login will return an error. |
bad748
|
143 |
*/ |
e81c27
|
144 |
- (void)logInWithPermissions:(NSArray<NSString *> *)permissions |
H |
145 |
fromViewController:(nullable UIViewController *)fromViewController |
|
146 |
handler:(nullable FBSDKLoginManagerLoginResultBlock)handler |
|
147 |
NS_SWIFT_NAME(logIn(permissions:from:handler:)); |
13e53a
|
148 |
|
H |
149 |
/** |
|
150 |
Requests user's permission to reathorize application's data access, after it has expired due to inactivity. |
|
151 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
|
152 |
automatically determined as best as possible. |
|
153 |
@param handler the callback. |
|
154 |
Use this method when you need to reathorize your app's access to user data via Graph API, after such an access has expired. |
|
155 |
You should provide as much context to the user as possible as to why you need to reauthorize the access, the scope of |
|
156 |
access being reathorized, and what added value your app provides when the access is reathorized. |
|
157 |
You can inspect the result.declinedPermissions to also provide more information to the user if they decline permissions. |
|
158 |
This method will present UI the user. You typically should call this if `[FBSDKAccessToken isDataAccessExpired]` returns true. |
|
159 |
*/ |
|
160 |
- (void)reauthorizeDataAccess:(UIViewController *)fromViewController |
e81c27
|
161 |
handler:(FBSDKLoginManagerLoginResultBlock)handler |
H |
162 |
NS_SWIFT_NAME(reauthorizeDataAccess(from:handler:)); |
13e53a
|
163 |
|
9febd9
|
164 |
/** |
W |
165 |
Logs the user out |
|
166 |
|
|
167 |
This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil]. |
bad748
|
168 |
*/ |
W |
169 |
- (void)logOut; |
|
170 |
|
|
171 |
@end |
e81c27
|
172 |
|
H |
173 |
NS_ASSUME_NONNULL_END |