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