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