commit | author | age
|
e0ec42
|
1 |
/* |
L |
2 |
* Copyright (c) Meta Platforms, Inc. and affiliates. |
|
3 |
* All rights reserved. |
|
4 |
* |
|
5 |
* This source code is licensed under the license found in the |
|
6 |
* LICENSE file in the root directory of this source tree. |
|
7 |
*/ |
|
8 |
|
|
9 |
#import <Foundation/Foundation.h> |
|
10 |
|
|
11 |
NS_ASSUME_NONNULL_BEGIN |
|
12 |
|
|
13 |
/** |
|
14 |
Dispatches the specified block on the main thread. |
|
15 |
@param block the block to dispatch |
|
16 |
*/ |
|
17 |
extern void fb_dispatch_on_main_thread(dispatch_block_t block); |
|
18 |
|
|
19 |
/** |
|
20 |
Dispatches the specified block on the default thread. |
|
21 |
@param block the block to dispatch |
|
22 |
*/ |
|
23 |
extern void fb_dispatch_on_default_thread(dispatch_block_t block); |
|
24 |
|
|
25 |
/** |
|
26 |
Describes the callback for appLinkFromURLInBackground. |
|
27 |
@param object the FBSDKAppLink representing the deferred App Link |
|
28 |
@param stop the error during the request, if any |
|
29 |
*/ |
|
30 |
typedef id _Nullable (^ FBSDKInvalidObjectHandler)(id object, BOOL *stop) |
|
31 |
NS_SWIFT_NAME(InvalidObjectHandler); |
|
32 |
|
|
33 |
NS_SWIFT_NAME(BasicUtility) |
|
34 |
@interface FBSDKBasicUtility : NSObject |
|
35 |
|
|
36 |
/** |
|
37 |
Converts an object into a JSON string. |
|
38 |
@param object The object to convert to JSON. |
|
39 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
40 |
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore. |
|
41 |
@return A JSON string or nil if the object cannot be converted to JSON. |
|
42 |
*/ |
|
43 |
+ (nullable NSString *)JSONStringForObject:(id)object |
|
44 |
error:(NSError *__autoreleasing *)errorRef |
|
45 |
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler; |
|
46 |
|
|
47 |
/** |
|
48 |
Sets an object for a key in a dictionary if it is not nil. |
|
49 |
@param dictionary The dictionary to set the value for. |
|
50 |
@param object The value to set after serializing to JSON. |
|
51 |
@param key The key to set the value for. |
|
52 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
53 |
@return NO if an error occurred while serializing the object, otherwise YES. |
|
54 |
*/ |
|
55 |
+ (BOOL) dictionary:(NSMutableDictionary<id, id> *)dictionary |
|
56 |
setJSONStringForObject:(id)object |
|
57 |
forKey:(id<NSCopying>)key |
|
58 |
error:(NSError *__autoreleasing *)errorRef; |
|
59 |
|
|
60 |
/** |
|
61 |
Converts a JSON string into an object |
|
62 |
@param string The JSON string to convert. |
|
63 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
64 |
@return An NSDictionary, NSArray, NSString or NSNumber containing the object representation, or nil if the string |
|
65 |
cannot be converted. |
|
66 |
*/ |
|
67 |
+ (nullable id)objectForJSONString:(NSString *)string error:(NSError *__autoreleasing *)errorRef; |
|
68 |
|
|
69 |
/** |
|
70 |
Constructs a query string from a dictionary. |
|
71 |
@param dictionary The dictionary with key/value pairs for the query string. |
|
72 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
73 |
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore. |
|
74 |
@return Query string representation of the parameters. |
|
75 |
*/ |
|
76 |
+ (nullable NSString *)queryStringWithDictionary:(NSDictionary<NSString *, id> *)dictionary |
|
77 |
error:(NSError *__autoreleasing *)errorRef |
|
78 |
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler; |
|
79 |
|
|
80 |
/** |
|
81 |
Converts simple value types to the string equivalent for serializing to a request query or body. |
|
82 |
@param value The value to be converted. |
|
83 |
@return The value that may have been converted if able (otherwise the input param). |
|
84 |
*/ |
|
85 |
+ (id)convertRequestValue:(id)value; |
|
86 |
|
|
87 |
/** |
|
88 |
Encodes a value for an URL. |
|
89 |
@param value The value to encode. |
|
90 |
@return The encoded value. |
|
91 |
*/ |
|
92 |
+ (NSString *)URLEncode:(NSString *)value; |
|
93 |
|
|
94 |
/** |
|
95 |
Parses a query string into a dictionary. |
|
96 |
@param queryString The query string value. |
|
97 |
@return A dictionary with the key/value pairs. |
|
98 |
*/ |
|
99 |
+ (NSDictionary<NSString *, NSString *> *)dictionaryWithQueryString:(NSString *)queryString; |
|
100 |
|
|
101 |
/** |
|
102 |
Decodes a value from an URL. |
|
103 |
@param value The value to decode. |
|
104 |
@return The decoded value. |
|
105 |
*/ |
|
106 |
+ (NSString *)URLDecode:(NSString *)value; |
|
107 |
|
|
108 |
/** |
|
109 |
Gzip data with default compression level if possible. |
|
110 |
@param data The raw data. |
|
111 |
@return nil if unable to gzip the data, otherwise gzipped data. |
|
112 |
*/ |
|
113 |
+ (nullable NSData *)gzip:(NSData *)data; |
|
114 |
|
|
115 |
+ (NSString *)anonymousID; |
|
116 |
+ (NSString *)persistenceFilePath:(NSString *)filename; |
|
117 |
+ (nullable NSString *)SHA256Hash:(nullable NSObject *)input; |
|
118 |
|
|
119 |
@end |
|
120 |
|
|
121 |
NS_ASSUME_NONNULL_END |