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 |
|
27 |
- Parameter result: the result of the authorization |
|
28 |
- Parameter 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 |
/** |
W |
114 |
the default audience. |
|
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 |
*/ |
W |
123 |
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior; |
|
124 |
|
9febd9
|
125 |
/** |
W |
126 |
|
|
127 |
- Warning:use logInWithReadPermissions:fromViewController:handler: instead |
bad748
|
128 |
*/ |
W |
129 |
- (void)logInWithReadPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
|
130 |
__attribute__ ((deprecated("use logInWithReadPermissions:fromViewController:handler: instead"))); |
|
131 |
|
9febd9
|
132 |
/** |
W |
133 |
|
|
134 |
- Warning:use logInWithPublishPermissions:fromViewController:handler: instead |
bad748
|
135 |
*/ |
W |
136 |
- (void)logInWithPublishPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
|
137 |
__attribute__ ((deprecated("use logInWithPublishPermissions:fromViewController:handler: instead"))); |
|
138 |
|
9febd9
|
139 |
/** |
W |
140 |
Logs the user in or authorizes additional permissions. |
|
141 |
- Parameter permissions: the optional array of permissions. Note this is converted to NSSet and is only |
bad748
|
142 |
an NSArray for the convenience of literal syntax. |
9febd9
|
143 |
- Parameter fromViewController: the view controller to present from. If nil, the topmost view controller will be |
bad748
|
144 |
automatically determined as best as possible. |
9febd9
|
145 |
- Parameter handler: the callback. |
W |
146 |
|
|
147 |
Use this method when asking for read permissions. You should only ask for permissions when they |
bad748
|
148 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
W |
149 |
provide more information to the user if they decline permissions. |
|
150 |
|
|
151 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
152 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
153 |
you could make that check at viewDidLoad. |
9febd9
|
154 |
You can only do one login call at a time. Calling a login method before the completion handler is called |
W |
155 |
on a previous login will return an error. |
bad748
|
156 |
*/ |
W |
157 |
- (void)logInWithReadPermissions:(NSArray *)permissions |
|
158 |
fromViewController:(UIViewController *)fromViewController |
|
159 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
160 |
|
9febd9
|
161 |
/** |
W |
162 |
Logs the user in or authorizes additional permissions. |
|
163 |
- Parameter permissions: the optional array of permissions. Note this is converted to NSSet and is only |
bad748
|
164 |
an NSArray for the convenience of literal syntax. |
9febd9
|
165 |
- Parameter fromViewController: the view controller to present from. If nil, the topmost view controller will be |
bad748
|
166 |
automatically determined as best as possible. |
9febd9
|
167 |
- Parameter handler: the callback. |
W |
168 |
|
|
169 |
Use this method when asking for publish permissions. You should only ask for permissions when they |
bad748
|
170 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
W |
171 |
provide more information to the user if they decline permissions. |
|
172 |
|
|
173 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
174 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
175 |
you could make that check at viewDidLoad. |
9febd9
|
176 |
You can only do one login call at a time. Calling a login method before the completion handler is called |
W |
177 |
on a previous login will return an error. |
bad748
|
178 |
*/ |
W |
179 |
- (void)logInWithPublishPermissions:(NSArray *)permissions |
|
180 |
fromViewController:(UIViewController *)fromViewController |
|
181 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
182 |
|
9febd9
|
183 |
/** |
W |
184 |
Logs the user out |
|
185 |
|
|
186 |
This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil]. |
bad748
|
187 |
*/ |
W |
188 |
- (void)logOut; |
|
189 |
|
9febd9
|
190 |
/** |
bad748
|
191 |
@method |
W |
192 |
|
9febd9
|
193 |
Issues an asynchronous renewCredentialsForAccount call to the device's Facebook account store. |
bad748
|
194 |
|
9febd9
|
195 |
- Parameter handler: The completion handler to call when the renewal is completed. This can be invoked on an arbitrary thread. |
bad748
|
196 |
|
9febd9
|
197 |
|
W |
198 |
This can be used to explicitly renew account credentials and is provided as a convenience wrapper around |
bad748
|
199 |
`[ACAccountStore renewCredentialsForAccount:completion]`. Note the method will not issue the renewal call if the the |
W |
200 |
Facebook account has not been set on the device, or if access had not been granted to the account (though the handler |
|
201 |
wil receive an error). |
|
202 |
|
|
203 |
If the `[FBSDKAccessToken currentAccessToken]` was from the account store, a succesful renewal will also set |
|
204 |
a new "currentAccessToken". |
|
205 |
*/ |
|
206 |
+ (void)renewSystemCredentials:(void (^)(ACAccountCredentialRenewResult result, NSError *error))handler; |
|
207 |
|
|
208 |
@end |