commit | author | age
|
2e29a3
|
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 |
*/ |
|
31 |
typedef id _Nullable (^ FBSDKInvalidObjectHandler)(id object, BOOL *stop) |
|
32 |
NS_SWIFT_NAME(InvalidObjectHandler); |
|
33 |
|
|
34 |
NS_SWIFT_NAME(BasicUtility) |
|
35 |
@interface FBSDKBasicUtility : NSObject |
|
36 |
|
|
37 |
/** |
|
38 |
Converts an object into a JSON string. |
|
39 |
@param object The object to convert to JSON. |
|
40 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
41 |
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore. |
|
42 |
@return A JSON string or nil if the object cannot be converted to JSON. |
|
43 |
*/ |
|
44 |
+ (nullable NSString *)JSONStringForObject:(id)object |
|
45 |
error:(NSError *__autoreleasing *)errorRef |
|
46 |
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler; |
|
47 |
|
|
48 |
/** |
|
49 |
Sets an object for a key in a dictionary if it is not nil. |
|
50 |
@param dictionary The dictionary to set the value for. |
|
51 |
@param object The value to set after serializing to JSON. |
|
52 |
@param key The key to set the value for. |
|
53 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
54 |
@return NO if an error occurred while serializing the object, otherwise YES. |
|
55 |
*/ |
|
56 |
+ (BOOL) dictionary:(NSMutableDictionary<id, id> *)dictionary |
|
57 |
setJSONStringForObject:(id)object |
|
58 |
forKey:(id<NSCopying>)key |
|
59 |
error:(NSError *__autoreleasing *)errorRef; |
|
60 |
|
|
61 |
/** |
|
62 |
Converts a JSON string into an object |
|
63 |
@param string The JSON string to convert. |
|
64 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
65 |
@return An NSDictionary, NSArray, NSString or NSNumber containing the object representation, or nil if the string |
|
66 |
cannot be converted. |
|
67 |
*/ |
|
68 |
+ (nullable id)objectForJSONString:(NSString *)string error:(NSError *__autoreleasing *)errorRef; |
|
69 |
|
|
70 |
/** |
|
71 |
Constructs a query string from a dictionary. |
|
72 |
@param dictionary The dictionary with key/value pairs for the query string. |
|
73 |
@param errorRef If an error occurs, upon return contains an NSError object that describes the problem. |
|
74 |
@param invalidObjectHandler Handles objects that are invalid, returning a replacement value or nil to ignore. |
|
75 |
@return Query string representation of the parameters. |
|
76 |
*/ |
|
77 |
+ (nullable NSString *)queryStringWithDictionary:(NSDictionary<NSString *, id> *)dictionary |
|
78 |
error:(NSError *__autoreleasing *)errorRef |
|
79 |
invalidObjectHandler:(nullable FBSDKInvalidObjectHandler)invalidObjectHandler; |
|
80 |
|
|
81 |
/** |
|
82 |
Converts simple value types to the string equivalent for serializing to a request query or body. |
|
83 |
@param value The value to be converted. |
|
84 |
@return The value that may have been converted if able (otherwise the input param). |
|
85 |
*/ |
|
86 |
+ (id)convertRequestValue:(id)value; |
|
87 |
|
|
88 |
/** |
|
89 |
Encodes a value for an URL. |
|
90 |
@param value The value to encode. |
|
91 |
@return The encoded value. |
|
92 |
*/ |
|
93 |
+ (NSString *)URLEncode:(NSString *)value; |
|
94 |
|
|
95 |
/** |
|
96 |
Parses a query string into a dictionary. |
|
97 |
@param queryString The query string value. |
|
98 |
@return A dictionary with the key/value pairs. |
|
99 |
*/ |
|
100 |
+ (NSDictionary<NSString *, NSString *> *)dictionaryWithQueryString:(NSString *)queryString; |
|
101 |
|
|
102 |
/** |
|
103 |
Decodes a value from an URL. |
|
104 |
@param value The value to decode. |
|
105 |
@return The decoded value. |
|
106 |
*/ |
|
107 |
+ (NSString *)URLDecode:(NSString *)value; |
|
108 |
|
|
109 |
/** |
|
110 |
Gzip data with default compression level if possible. |
|
111 |
@param data The raw data. |
|
112 |
@return nil if unable to gzip the data, otherwise gzipped data. |
|
113 |
*/ |
|
114 |
+ (nullable NSData *)gzip:(NSData *)data; |
|
115 |
|
|
116 |
+ (NSString *)anonymousID; |
|
117 |
+ (NSString *)persistenceFilePath:(NSString *)filename; |
|
118 |
+ (nullable NSString *)SHA256Hash:(nullable NSObject *)input; |
|
119 |
|
|
120 |
@end |
|
121 |
|
|
122 |
NS_ASSUME_NONNULL_END |