ALUtils.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // ALUtils.h
  3. // AppLovinSDK
  4. //
  5. // Created by Thomas So on 1/1/22.
  6. //
  7. #import <UIKit/UIKit.h>
  8. NS_ASSUME_NONNULL_BEGIN
  9. /**
  10. * Class containing utility functions for convenience of adapters development and integration.
  11. */
  12. @interface ALUtils : NSObject
  13. /**
  14. * @return The currently visible top view controller from the app's window(s).
  15. */
  16. + (UIViewController *)topViewControllerFromKeyWindow;
  17. /**
  18. * @return The app's current @c UIInterfaceOrientationMask.
  19. */
  20. + (UIInterfaceOrientationMask)currentOrientationMask;
  21. /**
  22. * @return The device display dimensions, respecting safe area.
  23. */
  24. + (CGRect)deviceSafeAreaDimensions;
  25. /**
  26. * @return If the app is running in an iOS simulator.
  27. */
  28. @property (class, nonatomic, readonly, getter=isSimulator) BOOL simulator;
  29. - (instancetype)init NS_UNAVAILABLE;
  30. @end
  31. @interface ALUtils (ALDeprecated)
  32. + (nullable NSNumber *)tcfConsentStatusForVendorIdentifier:(NSInteger)vendorIdentifier
  33. __deprecated_msg("This method has been deprecated and will be removed in a future SDK version. Please use -[ALPrivacySettings tcfVendorConsentStatusForIdentifier:] instead.");
  34. + (nullable NSNumber *)additionalConsentStatusForATPIdentifier:(NSInteger)atpIdentifier
  35. __deprecated_msg("This method has been deprecated and will be removed in a future SDK version. Please use -[ALPrivacySettings additionalConsentStatusForIdentifier:] instead.");
  36. @end
  37. @interface NSString (ALSdk)
  38. @property (nonatomic, assign, readonly, getter=al_isValidString) BOOL al_validString;
  39. @property (nonatomic, assign, readonly, getter=al_isValidURL) BOOL al_validURL;
  40. - (BOOL)al_isEqualToStringIgnoringCase:(NSString *)otherString;
  41. @end
  42. @interface NSDictionary (ALSdk)
  43. - (BOOL)al_boolForKey:(NSString *)key;
  44. - (BOOL)al_boolForKey:(NSString *)key defaultValue:(BOOL)defaultValue;
  45. - (nullable NSNumber *)al_numberForKey:(NSString *)key;
  46. - (nullable NSNumber *)al_numberForKey:(NSString *)key defaultValue:(nullable NSNumber *)defaultValue;
  47. - (nullable NSString *)al_stringForKey:(NSString *)key;
  48. - (nullable NSString *)al_stringForKey:(NSString *)key defaultValue:(nullable NSString *)defaultValue;
  49. - (nullable NSArray<NSNumber *> *)al_numberArrayForKey:(NSString *)key;
  50. - (nullable NSArray<NSNumber *> *)al_numberArrayForKey:(NSString *)key defaultValue:(nullable NSArray<NSNumber *> *)defaultValue;
  51. - (nullable NSArray *)al_arrayForKey:(NSString *)key;
  52. - (nullable NSArray *)al_arrayForKey:(NSString *)key defaultValue:(nullable NSArray *)defaultValue;
  53. - (nullable NSDictionary *)al_dictionaryForKey:(NSString *)key;
  54. - (nullable NSDictionary *)al_dictionaryForKey:(NSString *)key defaultValue:(nullable NSDictionary *)defaultValue;
  55. - (BOOL)al_containsValueForKey:(id)key;
  56. @end
  57. @interface NSNumber (ALSdk)
  58. @property (nonatomic, assign, readonly) NSTimeInterval al_timeIntervalValue;
  59. @end
  60. @interface UIView (ALSdk)
  61. - (void)al_pinToSuperview;
  62. @end
  63. @interface NSDate (ALSdk)
  64. + (NSTimeInterval)al_timeIntervalNow;
  65. @end
  66. @interface UIImageView (ALSdk)
  67. - (void)al_setImageWithURL:(NSURL *)URL;
  68. @end
  69. NS_ASSUME_NONNULL_END