FBSDKUtility.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  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. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. /// Class to contain common utility methods.
  11. NS_SWIFT_NAME(Utility)
  12. @interface FBSDKUtility : NSObject
  13. - (instancetype)init NS_UNAVAILABLE;
  14. + (instancetype)new NS_UNAVAILABLE;
  15. /**
  16. Parses a query string into a dictionary.
  17. @param queryString The query string value.
  18. @return A dictionary with the key/value pairs.
  19. */
  20. // UNCRUSTIFY_FORMAT_OFF
  21. + (NSDictionary<NSString *, NSString *> *)dictionaryWithQueryString:(NSString *)queryString
  22. NS_SWIFT_NAME(dictionary(withQuery:));
  23. // UNCRUSTIFY_FORMAT_ON
  24. /**
  25. Constructs a query string from a dictionary.
  26. @param dictionary The dictionary with key/value pairs for the query string.
  27. @param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
  28. @return Query string representation of the parameters.
  29. */
  30. // UNCRUSTIFY_FORMAT_OFF
  31. + (NSString *)queryStringWithDictionary:(NSDictionary<NSString *, id> *)dictionary
  32. error:(NSError **)errorRef
  33. NS_SWIFT_NAME(query(from:))
  34. __attribute__((swift_error(nonnull_error)));
  35. // UNCRUSTIFY_FORMAT_ON
  36. /**
  37. Decodes a value from an URL.
  38. @param value The value to decode.
  39. @return The decoded value.
  40. */
  41. // UNCRUSTIFY_FORMAT_OFF
  42. + (NSString *)URLDecode:(NSString *)value
  43. NS_SWIFT_NAME(decode(urlString:));
  44. // UNCRUSTIFY_FORMAT_ON
  45. /**
  46. Encodes a value for an URL.
  47. @param value The value to encode.
  48. @return The encoded value.
  49. */
  50. // UNCRUSTIFY_FORMAT_OFF
  51. + (NSString *)URLEncode:(NSString *)value
  52. NS_SWIFT_NAME(encode(urlString:));
  53. // UNCRUSTIFY_FORMAT_ON
  54. /**
  55. Creates a timer using Grand Central Dispatch.
  56. @param interval The interval to fire the timer, in seconds.
  57. @param block The code block to execute when timer is fired.
  58. @return The dispatch handle.
  59. */
  60. + (dispatch_source_t)startGCDTimerWithInterval:(double)interval block:(dispatch_block_t)block;
  61. /**
  62. Stop a timer that was started by startGCDTimerWithInterval.
  63. @param timer The dispatch handle received from startGCDTimerWithInterval.
  64. */
  65. + (void)stopGCDTimer:(dispatch_source_t)timer;
  66. /**
  67. Get SHA256 hased string of NSString/NSData
  68. @param input The data that needs to be hashed, it could be NSString or NSData.
  69. */
  70. // UNCRUSTIFY_FORMAT_OFF
  71. + (nullable NSString *)SHA256Hash:(NSObject *)input
  72. NS_SWIFT_NAME(sha256Hash(_:));
  73. // UNCRUSTIFY_FORMAT_ON
  74. /// Returns the graphdomain stored in FBSDKAuthenticationToken
  75. + (nullable NSString *)getGraphDomainFromToken;
  76. /**
  77. Internal Type exposed to facilitate transition to Swift.
  78. API Subject to change or removal without warning. Do not use.
  79. @warning INTERNAL - DO NOT USE
  80. */
  81. + (NSURL *)unversionedFacebookURLWithHostPrefix:(NSString *)hostPrefix
  82. path:(NSString *)path
  83. queryParameters:(NSDictionary<NSString *, id> *)queryParameters
  84. error:(NSError *__autoreleasing *)errorRef;
  85. @end
  86. NS_ASSUME_NONNULL_END