FIRDynamicLinks.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright 2018 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FIRDynamicLink.h"
  18. #import "FIRDynamicLinksCommon.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * @file FIRDynamicLinks.h
  22. * @abstract Firebase Dynamic Links
  23. */
  24. /**
  25. * @class FIRDynamicLinks
  26. * @abstract A class that checks for pending Dynamic Links and parses URLs.
  27. * This class is available on iOS only.
  28. */
  29. NS_EXTENSION_UNAVAILABLE_IOS("Firebase Dynamic Links is not supported for iOS extensions.")
  30. API_UNAVAILABLE(macos, tvos, watchos)
  31. NS_SWIFT_NAME(DynamicLinks)
  32. @interface FIRDynamicLinks : NSObject
  33. /**
  34. * @method dynamicLinks
  35. * @abstract Shared instance of FIRDynamicLinks.
  36. * @return Shared instance of FIRDynamicLinks.
  37. */
  38. + (instancetype)dynamicLinks NS_SWIFT_NAME(dynamicLinks());
  39. /**
  40. * @method shouldHandleDynamicLinkFromCustomSchemeURL:
  41. * @abstract Determine whether FIRDynamicLinks should handle the given URL. This does not
  42. * guarantee that |dynamicLinkFromCustomSchemeURL:| will return a non-nil value, but it means
  43. * the client should not attempt to handle the URL.
  44. * @param url Custom scheme URL.
  45. * @return Whether the URL can be handled by FIRDynamicLinks.
  46. */
  47. - (BOOL)shouldHandleDynamicLinkFromCustomSchemeURL:(NSURL *)url
  48. NS_SWIFT_NAME(shouldHandleDynamicLink(fromCustomSchemeURL:));
  49. /**
  50. * @method dynamicLinkFromCustomSchemeURL:
  51. * @abstract Get a Dynamic Link from a custom scheme URL. This method parses URLs with a custom
  52. * scheme, for instance, "comgoogleapp://google/link?deep_link_id=abc123". It is suggested to
  53. * call it inside your |UIApplicationDelegate|'s
  54. * |application:openURL:sourceApplication:annotation| and |application:openURL:options:|
  55. * methods.
  56. * @param url Custom scheme URL.
  57. * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
  58. */
  59. - (nullable FIRDynamicLink *)dynamicLinkFromCustomSchemeURL:(NSURL *)url
  60. NS_SWIFT_NAME(dynamicLink(fromCustomSchemeURL:));
  61. /**
  62. * @method dynamicLinkFromUniversalLinkURL:completion:
  63. * @abstract Get a Dynamic Link from a universal link URL. This method parses universal link
  64. * URLs, for instance,
  65. * "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
  66. * It is suggested to call it inside your |UIApplicationDelegate|'s
  67. * |application:continueUserActivity:restorationHandler:| method.
  68. * @param url Custom scheme URL.
  69. * @param completion A block that handles the outcome of attempting to get a Dynamic Link from a
  70. * universal link URL.
  71. */
  72. - (void)dynamicLinkFromUniversalLinkURL:(NSURL *)url
  73. completion:(void (^)(FIRDynamicLink *_Nullable dynamicLink,
  74. NSError *_Nullable error))completion
  75. NS_SWIFT_NAME(dynamicLink(fromUniversalLink:completion:));
  76. /**
  77. * @method dynamicLinkFromUniversalLinkURL:
  78. * @abstract Get a Dynamic Link from a universal link URL. This method parses universal link
  79. * URLs, for instance,
  80. * "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
  81. * It is suggested to call it inside your |UIApplicationDelegate|'s
  82. * |application:continueUserActivity:restorationHandler:| method.
  83. * @param url Custom scheme URL.
  84. * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
  85. */
  86. - (nullable FIRDynamicLink *)dynamicLinkFromUniversalLinkURL:(NSURL *)url
  87. NS_SWIFT_NAME(dynamicLink(fromUniversalLink:))
  88. DEPRECATED_MSG_ATTRIBUTE("Use dynamicLinkFromUniversalLinkURL:completion: instead.");
  89. /**
  90. * @method handleUniversalLink:completion:
  91. * @abstract Convenience method to handle a Universal Link whether it is long or short.
  92. * @param url A Universal Link URL.
  93. * @param completion A block that handles the outcome of attempting to create a FIRDynamicLink.
  94. * @return YES if FIRDynamicLinks is handling the link, otherwise, NO.
  95. */
  96. - (BOOL)handleUniversalLink:(NSURL *)url
  97. completion:(void (^)(FIRDynamicLink *_Nullable dynamicLink,
  98. NSError *_Nullable error))completion;
  99. /**
  100. * @method resolveShortLink:completion:
  101. * @abstract Retrieves the details of the Dynamic Link that the shortened URL represents.
  102. * @param url A Short Dynamic Link.
  103. * @param completion Block to be run upon completion.
  104. */
  105. - (void)resolveShortLink:(NSURL *)url
  106. completion:(void (^)(NSURL *_Nullable url, NSError *_Nullable error))completion;
  107. /**
  108. * @method matchesShortLinkFormat:
  109. * @abstract Determines if a given URL matches the given short Dynamic Link format.
  110. * @param url A URL.
  111. * @return YES if the URL is a short Dynamic Link, otherwise, NO.
  112. */
  113. - (BOOL)matchesShortLinkFormat:(NSURL *)url;
  114. /**
  115. * @method performDiagnosticsWithCompletion:
  116. * @abstract Performs basic FDL self diagnostic. Method effect on startup latency is quite small
  117. * and no user-visble UI is presented. This method should be used for debugging purposes.
  118. * App developers are encouraged to include output, generated by this method, to the support
  119. * requests sent to Firebase support.
  120. * @param completionHandler Handler that will be called when diagnostic completes.
  121. * If value of the completionHandler is nil than diagnostic output will be printed to
  122. * the standard output.
  123. * diagnosticOutput String that includes diagnostic information.
  124. * hasErrors Param will have YES value if diagnostic method detected error, NO otherwise.
  125. */
  126. + (void)performDiagnosticsWithCompletion:(void (^_Nullable)(NSString *diagnosticOutput,
  127. BOOL hasErrors))completionHandler;
  128. @end
  129. NS_ASSUME_NONNULL_END