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 <Accounts/Accounts.h> |
|
20 |
#import <Foundation/Foundation.h> |
|
21 |
#import <UIKit/UIKit.h> |
|
22 |
|
|
23 |
@class FBSDKLoginManagerLoginResult; |
|
24 |
|
9febd9
|
25 |
/** |
W |
26 |
Describes the call back to the FBSDKLoginManager |
13e53a
|
27 |
@param result the result of the authorization |
H |
28 |
@param error the authorization error, if any. |
bad748
|
29 |
*/ |
W |
30 |
typedef void (^FBSDKLoginManagerRequestTokenHandler)(FBSDKLoginManagerLoginResult *result, NSError *error); |
|
31 |
|
|
32 |
|
9febd9
|
33 |
/** |
W |
34 |
FBSDKDefaultAudience enum |
bad748
|
35 |
|
9febd9
|
36 |
Passed to open to indicate which default audience to use for sessions that post data to Facebook. |
bad748
|
37 |
|
9febd9
|
38 |
|
W |
39 |
|
bad748
|
40 |
Certain operations such as publishing a status or publishing a photo require an audience. When the user |
W |
41 |
grants an application permission to perform a publish operation, a default audience is selected as the |
|
42 |
publication ceiling for the application. This enumerated value allows the application to select which |
|
43 |
audience to ask the user to grant publish permission for. |
|
44 |
*/ |
|
45 |
typedef NS_ENUM(NSUInteger, FBSDKDefaultAudience) |
|
46 |
{ |
9febd9
|
47 |
/** Indicates that the user's friends are able to see posts made by the application */ |
bad748
|
48 |
FBSDKDefaultAudienceFriends = 0, |
9febd9
|
49 |
/** Indicates that only the user is able to see posts made by the application */ |
bad748
|
50 |
FBSDKDefaultAudienceOnlyMe, |
9febd9
|
51 |
/** Indicates that all Facebook users are able to see posts made by the application */ |
bad748
|
52 |
FBSDKDefaultAudienceEveryone, |
W |
53 |
}; |
|
54 |
|
9febd9
|
55 |
/** |
W |
56 |
FBSDKLoginBehavior enum |
bad748
|
57 |
|
9febd9
|
58 |
Passed to the \c FBSDKLoginManager to indicate how Facebook Login should be attempted. |
bad748
|
59 |
|
9febd9
|
60 |
|
W |
61 |
|
bad748
|
62 |
Facebook Login authorizes the application to act on behalf of the user, using the user's |
W |
63 |
Facebook account. Usually a Facebook Login will rely on an account maintained outside of |
|
64 |
the application, by the native Facebook application, the browser, or perhaps the device |
|
65 |
itself. This avoids the need for a user to enter their username and password directly, and |
|
66 |
provides the most secure and lowest friction way for a user to authorize the application to |
|
67 |
interact with Facebook. |
|
68 |
|
|
69 |
The \c FBSDKLoginBehavior enum specifies which log-in methods may be used. The SDK |
|
70 |
will determine the best behavior based on the current device (such as iOS version). |
|
71 |
*/ |
|
72 |
typedef NS_ENUM(NSUInteger, FBSDKLoginBehavior) |
|
73 |
{ |
9febd9
|
74 |
/** |
W |
75 |
This is the default behavior, and indicates logging in through the native |
bad748
|
76 |
Facebook app may be used. The SDK may still use Safari instead. |
W |
77 |
*/ |
|
78 |
FBSDKLoginBehaviorNative = 0, |
9febd9
|
79 |
/** |
W |
80 |
Attempts log in through the Safari or SFSafariViewController, if available. |
bad748
|
81 |
*/ |
W |
82 |
FBSDKLoginBehaviorBrowser, |
9febd9
|
83 |
/** |
W |
84 |
Attempts log in through the Facebook account currently signed in through |
bad748
|
85 |
the device Settings. |
W |
86 |
@note If the account is not available to the app (either not configured by user or |
|
87 |
as determined by the SDK) this behavior falls back to \c FBSDKLoginBehaviorNative. |
|
88 |
*/ |
|
89 |
FBSDKLoginBehaviorSystemAccount, |
9febd9
|
90 |
/** |
W |
91 |
Attempts log in through a modal \c UIWebView pop up |
bad748
|
92 |
|
W |
93 |
@note This behavior is only available to certain types of apps. Please check the Facebook |
|
94 |
Platform Policy to verify your app meets the restrictions. |
|
95 |
*/ |
|
96 |
FBSDKLoginBehaviorWeb, |
|
97 |
}; |
|
98 |
|
9febd9
|
99 |
/** |
W |
100 |
`FBSDKLoginManager` provides methods for logging the user in and out. |
|
101 |
|
|
102 |
`FBSDKLoginManager` works directly with `[FBSDKAccessToken currentAccessToken]` and |
bad748
|
103 |
sets the "currentAccessToken" upon successful authorizations (or sets `nil` in case of `logOut`). |
W |
104 |
|
|
105 |
You should check `[FBSDKAccessToken currentAccessToken]` before calling logIn* to see if there is |
|
106 |
a cached token available (typically in your viewDidLoad). |
|
107 |
|
|
108 |
If you are managing your own token instances outside of "currentAccessToken", you will need to set |
9febd9
|
109 |
"currentAccessToken" before calling logIn* to authorize further permissions on your tokens. |
bad748
|
110 |
*/ |
W |
111 |
@interface FBSDKLoginManager : NSObject |
|
112 |
|
9febd9
|
113 |
/** |
9f077b
|
114 |
Auth type |
H |
115 |
*/ |
|
116 |
@property (strong, nonatomic) NSString *authType; |
|
117 |
/** |
9febd9
|
118 |
the default audience. |
W |
119 |
|
|
120 |
you should set this if you intend to ask for publish permissions. |
bad748
|
121 |
*/ |
W |
122 |
@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience; |
|
123 |
|
9febd9
|
124 |
/** |
W |
125 |
the login behavior |
bad748
|
126 |
*/ |
W |
127 |
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior; |
|
128 |
|
9febd9
|
129 |
/** |
W |
130 |
|
13e53a
|
131 |
@warning use logInWithReadPermissions:fromViewController:handler: instead |
bad748
|
132 |
*/ |
W |
133 |
- (void)logInWithReadPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
13e53a
|
134 |
DEPRECATED_MSG_ATTRIBUTE("use logInWithReadPermissions:fromViewController:handler: instead"); |
bad748
|
135 |
|
9febd9
|
136 |
/** |
W |
137 |
|
13e53a
|
138 |
@warning use logInWithPublishPermissions:fromViewController:handler: instead |
bad748
|
139 |
*/ |
W |
140 |
- (void)logInWithPublishPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
13e53a
|
141 |
DEPRECATED_MSG_ATTRIBUTE("use logInWithPublishPermissions:fromViewController:handler: instead"); |
bad748
|
142 |
|
9febd9
|
143 |
/** |
W |
144 |
Logs the user in or authorizes additional permissions. |
13e53a
|
145 |
@param permissions the optional array of permissions. Note this is converted to NSSet and is only |
bad748
|
146 |
an NSArray for the convenience of literal syntax. |
13e53a
|
147 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
bad748
|
148 |
automatically determined as best as possible. |
13e53a
|
149 |
@param handler the callback. |
9febd9
|
150 |
|
W |
151 |
Use this method when asking for read permissions. You should only ask for permissions when they |
bad748
|
152 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
W |
153 |
provide more information to the user if they decline permissions. |
|
154 |
|
|
155 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
156 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
157 |
you could make that check at viewDidLoad. |
9febd9
|
158 |
You can only do one login call at a time. Calling a login method before the completion handler is called |
W |
159 |
on a previous login will return an error. |
bad748
|
160 |
*/ |
W |
161 |
- (void)logInWithReadPermissions:(NSArray *)permissions |
|
162 |
fromViewController:(UIViewController *)fromViewController |
|
163 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
164 |
|
9febd9
|
165 |
/** |
W |
166 |
Logs the user in or authorizes additional permissions. |
13e53a
|
167 |
@param permissions the optional array of permissions. Note this is converted to NSSet and is only |
bad748
|
168 |
an NSArray for the convenience of literal syntax. |
13e53a
|
169 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
bad748
|
170 |
automatically determined as best as possible. |
13e53a
|
171 |
@param handler the callback. |
9febd9
|
172 |
|
W |
173 |
Use this method when asking for publish permissions. You should only ask for permissions when they |
bad748
|
174 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
W |
175 |
provide more information to the user if they decline permissions. |
|
176 |
|
|
177 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
178 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
179 |
you could make that check at viewDidLoad. |
9febd9
|
180 |
You can only do one login call at a time. Calling a login method before the completion handler is called |
W |
181 |
on a previous login will return an error. |
bad748
|
182 |
*/ |
W |
183 |
- (void)logInWithPublishPermissions:(NSArray *)permissions |
|
184 |
fromViewController:(UIViewController *)fromViewController |
|
185 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
186 |
|
13e53a
|
187 |
|
H |
188 |
/** |
|
189 |
Requests user's permission to reathorize application's data access, after it has expired due to inactivity. |
|
190 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
|
191 |
automatically determined as best as possible. |
|
192 |
@param handler the callback. |
|
193 |
Use this method when you need to reathorize your app's access to user data via Graph API, after such an access has expired. |
|
194 |
You should provide as much context to the user as possible as to why you need to reauthorize the access, the scope of |
|
195 |
access being reathorized, and what added value your app provides when the access is reathorized. |
|
196 |
You can inspect the result.declinedPermissions to also provide more information to the user if they decline permissions. |
|
197 |
This method will present UI the user. You typically should call this if `[FBSDKAccessToken isDataAccessExpired]` returns true. |
|
198 |
*/ |
|
199 |
- (void)reauthorizeDataAccess:(UIViewController *)fromViewController |
|
200 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
201 |
|
9febd9
|
202 |
/** |
W |
203 |
Logs the user out |
|
204 |
|
|
205 |
This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil]. |
bad748
|
206 |
*/ |
W |
207 |
- (void)logOut; |
|
208 |
|
9febd9
|
209 |
/** |
bad748
|
210 |
@method |
W |
211 |
|
9febd9
|
212 |
Issues an asynchronous renewCredentialsForAccount call to the device's Facebook account store. |
bad748
|
213 |
|
13e53a
|
214 |
@param handler The completion handler to call when the renewal is completed. This can be invoked on an arbitrary thread. |
bad748
|
215 |
|
9febd9
|
216 |
|
W |
217 |
This can be used to explicitly renew account credentials and is provided as a convenience wrapper around |
bad748
|
218 |
`[ACAccountStore renewCredentialsForAccount:completion]`. Note the method will not issue the renewal call if the the |
W |
219 |
Facebook account has not been set on the device, or if access had not been granted to the account (though the handler |
|
220 |
wil receive an error). |
|
221 |
|
|
222 |
If the `[FBSDKAccessToken currentAccessToken]` was from the account store, a succesful renewal will also set |
|
223 |
a new "currentAccessToken". |
|
224 |
*/ |
|
225 |
+ (void)renewSystemCredentials:(void (^)(ACAccountCredentialRenewResult result, NSError *error))handler; |
|
226 |
|
|
227 |
@end |