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 |
|
|
21 |
#import "FBSDKConstants.h" |
|
22 |
|
e81c27
|
23 |
NS_ASSUME_NONNULL_BEGIN |
H |
24 |
|
bad748
|
25 |
@class FBSDKGraphErrorRecoveryProcessor; |
W |
26 |
@class FBSDKGraphRequest; |
|
27 |
|
9febd9
|
28 |
/** |
W |
29 |
Defines a delegate for `FBSDKGraphErrorRecoveryProcessor`. |
bad748
|
30 |
*/ |
e81c27
|
31 |
NS_SWIFT_NAME(GraphErrorRecoveryProcessorDelegate) |
bad748
|
32 |
@protocol FBSDKGraphErrorRecoveryProcessorDelegate<NSObject> |
W |
33 |
|
9febd9
|
34 |
/** |
W |
35 |
Indicates the error recovery has been attempted. |
13e53a
|
36 |
@param processor the processor instance. |
H |
37 |
@param didRecover YES if the recovery was successful. |
|
38 |
@param error the error that that was attempted to be recovered from. |
bad748
|
39 |
*/ |
e81c27
|
40 |
- (void)processorDidAttemptRecovery:(FBSDKGraphErrorRecoveryProcessor *)processor |
H |
41 |
didRecover:(BOOL)didRecover |
|
42 |
error:(nullable NSError *)error; |
bad748
|
43 |
|
W |
44 |
@optional |
9febd9
|
45 |
/** |
W |
46 |
Indicates the processor is about to process the error. |
13e53a
|
47 |
@param processor the processor instance. |
H |
48 |
@param error the error is about to be processed. |
9febd9
|
49 |
|
W |
50 |
return NO if the processor should not process the error. For example, |
bad748
|
51 |
if you want to prevent alerts of localized messages but otherwise perform retries and recoveries, |
13e53a
|
52 |
you could return NO for errors where userInfo[FBSDKGraphRequestErrorKey] equal to FBSDKGraphRequestErrorOther |
bad748
|
53 |
*/ |
e81c27
|
54 |
- (BOOL)processorWillProcessError:(FBSDKGraphErrorRecoveryProcessor *)processor |
H |
55 |
error:(nullable NSError *)error; |
bad748
|
56 |
|
W |
57 |
@end |
e81c27
|
58 |
|
H |
59 |
NS_ASSUME_NONNULL_END |
|
60 |
|
|
61 |
NS_ASSUME_NONNULL_BEGIN |
bad748
|
62 |
|
9febd9
|
63 |
/** |
W |
64 |
Defines a type that can process Facebook NSErrors with best practices. |
|
65 |
|
|
66 |
Facebook NSErrors can contain FBSDKErrorRecoveryAttempting instances to recover from errors, or |
bad748
|
67 |
localized messages to present to the user. This class will process the instances as follows: |
W |
68 |
|
13e53a
|
69 |
1. If the error is temporary as indicated by FBSDKGraphRequestErrorKey, assume the recovery succeeded and |
bad748
|
70 |
notify the delegate. |
W |
71 |
2. If a FBSDKErrorRecoveryAttempting instance is available, display an alert (dispatched to main thread) |
|
72 |
with the recovery options and call the instance's [ attemptRecoveryFromError:optionIndex:...]. |
|
73 |
3. If a FBSDKErrorRecoveryAttempting is not available, check the userInfo for FBSDKLocalizedErrorDescriptionKey |
|
74 |
and present that in an alert (dispatched to main thread). |
|
75 |
|
|
76 |
By default, FBSDKGraphRequests use this type to process errors and retry the request upon a successful |
|
77 |
recovery. |
|
78 |
|
|
79 |
Note that Facebook recovery attempters can present UI or even cause app switches (such as to login). Any such |
|
80 |
work is dispatched to the main thread (therefore your request handlers may then run on the main thread). |
|
81 |
|
e81c27
|
82 |
Login recovery requires FBSDKLoginKit. Login will prompt the user |
bad748
|
83 |
for all permissions last granted. If any are declined on the new request, the recovery is not successful but |
W |
84 |
the `[FBSDKAccessToken currentAccessToken]` might still have been updated. |
|
85 |
. |
|
86 |
*/ |
e81c27
|
87 |
NS_SWIFT_UNAVAILABLE("") |
bad748
|
88 |
@interface FBSDKGraphErrorRecoveryProcessor : NSObject |
W |
89 |
|
9febd9
|
90 |
/** |
W |
91 |
Gets the delegate. Note this is a strong reference, and is nil'ed out after recovery is complete. |
bad748
|
92 |
*/ |
e81c27
|
93 |
@property (nonatomic, strong, readonly, nullable) id<FBSDKGraphErrorRecoveryProcessorDelegate>delegate; |
bad748
|
94 |
|
9febd9
|
95 |
/** |
W |
96 |
Attempts to process the error, return YES if the error can be processed. |
13e53a
|
97 |
@param error the error to process. |
H |
98 |
@param request the related request that may be reissued. |
|
99 |
@param delegate the delegate that will be retained until recovery is complete. |
bad748
|
100 |
*/ |
e81c27
|
101 |
- (BOOL)processError:(NSError *)error |
H |
102 |
request:(FBSDKGraphRequest *)request |
|
103 |
delegate:(nullable id<FBSDKGraphErrorRecoveryProcessorDelegate>)delegate; |
bad748
|
104 |
|
9febd9
|
105 |
/** |
W |
106 |
The callback for FBSDKErrorRecoveryAttempting |
13e53a
|
107 |
@param didRecover if the recovery succeeded |
H |
108 |
@param contextInfo unused |
bad748
|
109 |
*/ |
e81c27
|
110 |
- (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(nullable void *)contextInfo; |
bad748
|
111 |
|
W |
112 |
@end |
e81c27
|
113 |
|
H |
114 |
NS_ASSUME_NONNULL_END |