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 |
|
|
25 |
/*! |
|
26 |
@abstract Describes the call back to the FBSDKLoginManager |
|
27 |
@param result the result of the authorization |
|
28 |
@param error the authorization error, if any. |
|
29 |
*/ |
|
30 |
typedef void (^FBSDKLoginManagerRequestTokenHandler)(FBSDKLoginManagerLoginResult *result, NSError *error); |
|
31 |
|
|
32 |
|
|
33 |
/*! |
|
34 |
@typedef FBSDKDefaultAudience enum |
|
35 |
|
|
36 |
@abstract |
|
37 |
Passed to open to indicate which default audience to use for sessions that post data to Facebook. |
|
38 |
|
|
39 |
@discussion |
|
40 |
Certain operations such as publishing a status or publishing a photo require an audience. When the user |
|
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 |
{ |
|
47 |
/*! Indicates that the user's friends are able to see posts made by the application */ |
|
48 |
FBSDKDefaultAudienceFriends = 0, |
|
49 |
/*! Indicates that only the user is able to see posts made by the application */ |
|
50 |
FBSDKDefaultAudienceOnlyMe, |
|
51 |
/*! Indicates that all Facebook users are able to see posts made by the application */ |
|
52 |
FBSDKDefaultAudienceEveryone, |
|
53 |
}; |
|
54 |
|
|
55 |
/*! |
|
56 |
@typedef FBSDKLoginBehavior enum |
|
57 |
|
|
58 |
@abstract |
|
59 |
Passed to the \c FBSDKLoginManager to indicate how Facebook Login should be attempted. |
|
60 |
|
|
61 |
@discussion |
|
62 |
Facebook Login authorizes the application to act on behalf of the user, using the user's |
|
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 |
{ |
|
74 |
/*! |
|
75 |
@abstract This is the default behavior, and indicates logging in through the native |
|
76 |
Facebook app may be used. The SDK may still use Safari instead. |
|
77 |
*/ |
|
78 |
FBSDKLoginBehaviorNative = 0, |
|
79 |
/*! |
|
80 |
@abstract Attempts log in through the Safari or SFSafariViewController, if available. |
|
81 |
*/ |
|
82 |
FBSDKLoginBehaviorBrowser, |
|
83 |
/*! |
|
84 |
@abstract Attempts log in through the Facebook account currently signed in through |
|
85 |
the device Settings. |
|
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, |
|
90 |
/*! |
|
91 |
@abstract Attemps log in through a modal \c UIWebView pop up |
|
92 |
|
|
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 |
|
|
99 |
/*! |
|
100 |
@abstract `FBSDKLoginManager` provides methods for logging the user in and out. |
|
101 |
@discussion `FBSDKLoginManager` works directly with `[FBSDKAccessToken currentAccessToken]` and |
|
102 |
sets the "currentAccessToken" upon successful authorizations (or sets `nil` in case of `logOut`). |
|
103 |
|
|
104 |
You should check `[FBSDKAccessToken currentAccessToken]` before calling logIn* to see if there is |
|
105 |
a cached token available (typically in your viewDidLoad). |
|
106 |
|
|
107 |
If you are managing your own token instances outside of "currentAccessToken", you will need to set |
|
108 |
"currentAccessToken" before calling logIn* to authorize futher permissions on your tokens. |
|
109 |
*/ |
|
110 |
@interface FBSDKLoginManager : NSObject |
|
111 |
|
|
112 |
/*! |
|
113 |
@abstract the default audience. |
|
114 |
@discussion you should set this if you intend to ask for publish permissions. |
|
115 |
*/ |
|
116 |
@property (assign, nonatomic) FBSDKDefaultAudience defaultAudience; |
|
117 |
|
|
118 |
/*! |
|
119 |
@abstract the login behavior |
|
120 |
*/ |
|
121 |
@property (assign, nonatomic) FBSDKLoginBehavior loginBehavior; |
|
122 |
|
|
123 |
/*! |
|
124 |
@deprecated use logInWithReadPermissions:fromViewController:handler: instead |
|
125 |
*/ |
|
126 |
- (void)logInWithReadPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
|
127 |
__attribute__ ((deprecated("use logInWithReadPermissions:fromViewController:handler: instead"))); |
|
128 |
|
|
129 |
/*! |
|
130 |
@deprecated use logInWithPublishPermissions:fromViewController:handler: instead |
|
131 |
*/ |
|
132 |
- (void)logInWithPublishPermissions:(NSArray *)permissions handler:(FBSDKLoginManagerRequestTokenHandler)handler |
|
133 |
__attribute__ ((deprecated("use logInWithPublishPermissions:fromViewController:handler: instead"))); |
|
134 |
|
|
135 |
/*! |
|
136 |
@abstract Logs the user in or authorizes additional permissions. |
|
137 |
@param permissions the optional array of permissions. Note this is converted to NSSet and is only |
|
138 |
an NSArray for the convenience of literal syntax. |
|
139 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
|
140 |
automatically determined as best as possible. |
|
141 |
@param handler the callback. |
|
142 |
@discussion Use this method when asking for read permissions. You should only ask for permissions when they |
|
143 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
|
144 |
provide more information to the user if they decline permissions. |
|
145 |
|
|
146 |
If `[FBSDKAccessToken currentAccessToken]` is not nil, it will be treated as a reauthorization for that user |
|
147 |
and will pass the "rerequest" flag to the login dialog. |
|
148 |
|
|
149 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
150 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
151 |
you could make that check at viewDidLoad. |
|
152 |
*/ |
|
153 |
- (void)logInWithReadPermissions:(NSArray *)permissions |
|
154 |
fromViewController:(UIViewController *)fromViewController |
|
155 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
156 |
|
|
157 |
/*! |
|
158 |
@abstract Logs the user in or authorizes additional permissions. |
|
159 |
@param permissions the optional array of permissions. Note this is converted to NSSet and is only |
|
160 |
an NSArray for the convenience of literal syntax. |
|
161 |
@param fromViewController the view controller to present from. If nil, the topmost view controller will be |
|
162 |
automatically determined as best as possible. |
|
163 |
@param handler the callback. |
|
164 |
@discussion Use this method when asking for publish permissions. You should only ask for permissions when they |
|
165 |
are needed and explain the value to the user. You can inspect the result.declinedPermissions to also |
|
166 |
provide more information to the user if they decline permissions. |
|
167 |
|
|
168 |
If `[FBSDKAccessToken currentAccessToken]` is not nil, it will be treated as a reauthorization for that user |
|
169 |
and will pass the "rerequest" flag to the login dialog. |
|
170 |
|
|
171 |
This method will present UI the user. You typically should check if `[FBSDKAccessToken currentAccessToken]` |
|
172 |
already contains the permissions you need before asking to reduce unnecessary app switching. For example, |
|
173 |
you could make that check at viewDidLoad. |
|
174 |
*/ |
|
175 |
- (void)logInWithPublishPermissions:(NSArray *)permissions |
|
176 |
fromViewController:(UIViewController *)fromViewController |
|
177 |
handler:(FBSDKLoginManagerRequestTokenHandler)handler; |
|
178 |
|
|
179 |
/*! |
|
180 |
@abstract Logs the user out |
|
181 |
@discussion This calls [FBSDKAccessToken setCurrentAccessToken:nil] and [FBSDKProfile setCurrentProfile:nil]. |
|
182 |
*/ |
|
183 |
- (void)logOut; |
|
184 |
|
|
185 |
/*! |
|
186 |
@method |
|
187 |
|
|
188 |
@abstract Issues an asychronous renewCredentialsForAccount call to the device's Facebook account store. |
|
189 |
|
|
190 |
@param handler The completion handler to call when the renewal is completed. This can be invoked on an arbitrary thread. |
|
191 |
|
|
192 |
@discussion This can be used to explicitly renew account credentials and is provided as a convenience wrapper around |
|
193 |
`[ACAccountStore renewCredentialsForAccount:completion]`. Note the method will not issue the renewal call if the the |
|
194 |
Facebook account has not been set on the device, or if access had not been granted to the account (though the handler |
|
195 |
wil receive an error). |
|
196 |
|
|
197 |
If the `[FBSDKAccessToken currentAccessToken]` was from the account store, a succesful renewal will also set |
|
198 |
a new "currentAccessToken". |
|
199 |
*/ |
|
200 |
+ (void)renewSystemCredentials:(void (^)(ACAccountCredentialRenewResult result, NSError *error))handler; |
|
201 |
|
|
202 |
@end |