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