FBSDKURL.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #if !TARGET_OS_TV
  9. #import <Foundation/Foundation.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. @protocol FBSDKAppLink;
  12. @protocol FBSDKAppLinkCreating;
  13. /**
  14. Provides a set of utilities for working with NSURLs, such as parsing of query parameters
  15. and handling for App Link requests.
  16. */
  17. NS_SWIFT_NAME(AppLinkURL)
  18. @interface FBSDKURL : NSObject <FBSDKAppLinkURL>
  19. - (instancetype)init NS_UNAVAILABLE;
  20. + (instancetype)new NS_UNAVAILABLE;
  21. /**
  22. Creates a link target from a raw URL.
  23. On success, this posts the FBSDKAppLinkParseEventName measurement event. If you are constructing the FBSDKURL within your application delegate's
  24. application:openURL:sourceApplication:annotation:, you should instead use URLWithInboundURL:sourceApplication:
  25. to support better FBSDKMeasurementEvent notifications
  26. @param url The instance of `NSURL` to create FBSDKURL from.
  27. */
  28. // UNCRUSTIFY_FORMAT_OFF
  29. + (instancetype)URLWithURL:(NSURL *)url
  30. NS_SWIFT_NAME(init(url:));
  31. // UNCRUSTIFY_FORMAT_ON
  32. /**
  33. Creates a link target from a raw URL received from an external application. This is typically called from the app delegate's
  34. application:openURL:sourceApplication:annotation: and will post the FBSDKAppLinkNavigateInEventName measurement event.
  35. @param url The instance of `NSURL` to create FBSDKURL from.
  36. @param sourceApplication the bundle ID of the app that is requesting your app to open the URL. The same sourceApplication in application:openURL:sourceApplication:annotation:
  37. */
  38. // UNCRUSTIFY_FORMAT_OFF
  39. + (instancetype)URLWithInboundURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication
  40. NS_SWIFT_NAME(init(inboundURL:sourceApplication:));
  41. // UNCRUSTIFY_FORMAT_ON
  42. /**
  43. Gets the target URL. If the link is an App Link, this is the target of the App Link.
  44. Otherwise, it is the url that created the target.
  45. */
  46. @property (nonatomic, readonly, strong) NSURL *targetURL;
  47. /// Gets the query parameters for the target, parsed into an NSDictionary.
  48. @property (nonatomic, readonly, strong) NSDictionary<NSString *, id> *targetQueryParameters;
  49. /**
  50. If this link target is an App Link, this is the data found in al_applink_data.
  51. Otherwise, it is nil.
  52. */
  53. @property (nullable, nonatomic, readonly, strong) NSDictionary<NSString *, id> *appLinkData;
  54. /// If this link target is an App Link, this is the data found in extras.
  55. @property (nullable, nonatomic, readonly, strong) NSDictionary<NSString *, id> *appLinkExtras;
  56. /// The App Link indicating how to navigate back to the referer app, if any.
  57. @property (nullable, nonatomic, readonly, strong) id<FBSDKAppLink> appLinkReferer;
  58. /// The URL that was used to create this FBSDKURL.
  59. @property (nonatomic, readonly, strong) NSURL *inputURL;
  60. /// The query parameters of the inputURL, parsed into an NSDictionary.
  61. @property (nonatomic, readonly, strong) NSDictionary<NSString *, id> *inputQueryParameters;
  62. /// The flag indicating whether the URL comes from auto app link
  63. @property (nonatomic, readonly, getter = isAutoAppLink) BOOL isAutoAppLink;
  64. /**
  65. Internal method exposed to facilitate transition to Swift.
  66. API Subject to change or removal without warning. Do not use.
  67. @warning INTERNAL - DO NOT USE
  68. */
  69. // UNCRUSTIFY_FORMAT_OFF
  70. + (void)configureWithSettings:(id<FBSDKSettings>)settings
  71. appLinkFactory:(id<FBSDKAppLinkCreating>)appLinkFactory
  72. appLinkTargetFactory:(id<FBSDKAppLinkTargetCreating>)appLinkTargetFactory
  73. appLinkEventPoster:(id<FBSDKAppLinkEventPosting>)appLinkEventPoster
  74. NS_SWIFT_NAME(configure(settings:appLinkFactory:appLinkTargetFactory:appLinkEventPoster:));
  75. // UNCRUSTIFY_FORMAT_ON
  76. @end
  77. NS_ASSUME_NONNULL_END
  78. #endif