FIRDynamicLinks.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. */
  28. NS_SWIFT_NAME(DynamicLinks)
  29. @interface FIRDynamicLinks : NSObject
  30. /**
  31. * @method dynamicLinks
  32. * @abstract Shared instance of FIRDynamicLinks.
  33. * @return Shared instance of FIRDynamicLinks.
  34. */
  35. + (instancetype)dynamicLinks NS_SWIFT_NAME(dynamicLinks());
  36. /**
  37. * @method shouldHandleDynamicLinkFromCustomSchemeURL:
  38. * @abstract Determine whether FIRDynamicLinks should handle the given URL. This does not
  39. * guarantee that |dynamicLinkFromCustomSchemeURL:| will return a non-nil value, but it means
  40. * the client should not attempt to handle the URL.
  41. * @param url Custom scheme URL.
  42. * @return Whether the URL can be handled by FIRDynamicLinks.
  43. */
  44. - (BOOL)shouldHandleDynamicLinkFromCustomSchemeURL:(NSURL *)url
  45. NS_SWIFT_NAME(shouldHandleDynamicLink(fromCustomSchemeURL:));
  46. /**
  47. * @method dynamicLinkFromCustomSchemeURL:
  48. * @abstract Get a Dynamic Link from a custom scheme URL. This method parses URLs with a custom
  49. * scheme, for instance, "comgoogleapp://google/link?deep_link_id=abc123". It is suggested to
  50. * call it inside your |UIApplicationDelegate|'s
  51. * |application:openURL:sourceApplication:annotation| and |application:openURL:options:|
  52. * methods.
  53. * @param url Custom scheme URL.
  54. * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
  55. */
  56. - (nullable FIRDynamicLink *)dynamicLinkFromCustomSchemeURL:(NSURL *)url
  57. NS_SWIFT_NAME(dynamicLink(fromCustomSchemeURL:));
  58. /**
  59. * @method dynamicLinkFromUniversalLinkURL:
  60. * @abstract Get a Dynamic Link from a universal link URL. This method parses universal link
  61. * URLs, for instance,
  62. * "https://example.page.link?link=https://www.google.com&ibi=com.google.app&ius=comgoogleapp".
  63. * It is suggested to call it inside your |UIApplicationDelegate|'s
  64. * |application:continueUserActivity:restorationHandler:| method.
  65. * @param url Custom scheme URL.
  66. * @return Dynamic Link object if the URL is valid and has link parameter, otherwise nil.
  67. */
  68. - (nullable FIRDynamicLink *)dynamicLinkFromUniversalLinkURL:(NSURL *)url
  69. NS_SWIFT_NAME(dynamicLink(fromUniversalLink:));
  70. /**
  71. * @method handleUniversalLink:completion:
  72. * @abstract Convenience method to handle a Universal Link whether it is long or short. A long link
  73. * will call the handler immediately, but a short link may not.
  74. * @param url A Universal Link URL.
  75. * @param completion A block that handles the outcome of attempting to create a FIRDynamicLink.
  76. * @return YES if FIRDynamicLinks is handling the link, otherwise, NO.
  77. */
  78. - (BOOL)handleUniversalLink:(NSURL *)url completion:(FIRDynamicLinkUniversalLinkHandler)completion;
  79. /**
  80. * @method resolveShortLink:completion:
  81. * @abstract Retrieves the details of the Dynamic Link that the shortened URL represents.
  82. * @param url A Short Dynamic Link.
  83. * @param completion Block to be run upon completion.
  84. */
  85. - (void)resolveShortLink:(NSURL *)url completion:(FIRDynamicLinkResolverHandler)completion;
  86. /**
  87. * @method matchesShortLinkFormat:
  88. * @abstract Determines if a given URL matches the given short Dynamic Link format.
  89. * @param url A URL.
  90. * @return YES if the URL is a short Dynamic Link, otherwise, NO.
  91. */
  92. - (BOOL)matchesShortLinkFormat:(NSURL *)url;
  93. /**
  94. * @method performDiagnosticsWithCompletion:
  95. * @abstract Performs basic FDL self diagnostic. Method effect on startup latency is quite small
  96. * and no user-visble UI is presented. This method should be used for debugging purposes.
  97. * App developers are encouraged to include output, generated by this method, to the support
  98. * requests sent to Firebase support.
  99. * @param completionHandler Handler that will be called when diagnostic completes.
  100. * If value of the completionHandler is nil than diagnostic output will be printed to
  101. * the standard output.
  102. * diagnosticOutput String that includes diagnostic information.
  103. * hasErrors Param will have YES value if diagnostic method detected error, NO otherwise.
  104. */
  105. + (void)performDiagnosticsWithCompletion:(void (^_Nullable)(NSString *diagnosticOutput,
  106. BOOL hasErrors))completionHandler;
  107. @end
  108. NS_ASSUME_NONNULL_END