FDLUtilities.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. NS_ASSUME_NONNULL_BEGIN
  18. FOUNDATION_EXPORT NSString *const kFIRDLParameterDeepLinkIdentifier;
  19. FOUNDATION_EXPORT NSString *const kFIRDLParameterLink;
  20. FOUNDATION_EXPORT NSString *const kFIRDLParameterMinimumAppVersion;
  21. FOUNDATION_EXPORT NSString *const kFIRDLParameterSource;
  22. FOUNDATION_EXPORT NSString *const kFIRDLParameterMedium;
  23. FOUNDATION_EXPORT NSString *const kFIRDLParameterCampaign;
  24. FOUNDATION_EXPORT NSString *const kFIRDLParameterMatchType;
  25. FOUNDATION_EXPORT NSString *const kFIRDLParameterInviteId;
  26. FOUNDATION_EXPORT NSString *const kFIRDLParameterWeakMatchEndpoint;
  27. FOUNDATION_EXPORT NSString *const kFIRDLParameterMatchMessage;
  28. FOUNDATION_EXPORT NSString *const kFIRDLParameterRequestIPVersion;
  29. /**
  30. * After a Dynamic Link URL is opened in Safari, a cookie is dropped on the domain goo.gl. When a
  31. * specific URL is used, JavaScript checks if there's a cookie and, if it exists, redirects to the
  32. * custom-scheme URL stored in it. That causes application:openURL:options: to be called in
  33. * AppDelegate with the custom-scheme URL. This method creates and returns the URL required to check
  34. * for the presence of the FDL cookie on goo.gl.
  35. */
  36. NSURL *FIRDLCookieRetrievalURL(NSString *urlScheme, NSString *bundleID);
  37. /**
  38. * Creates a URL query string from the contents of an NSDictionary. Single-percent-encoded using
  39. * allowed query characters.
  40. */
  41. NSString *FIRDLURLQueryStringFromDictionary(NSDictionary<NSString *, NSString *> *dictionary);
  42. /**
  43. * @fn FIRDLDictionaryFromQuery
  44. * @abstract This receives a URL query parameter string and parses it into a dictionary that
  45. * represents the query. This method is necessary as |gtm_dictionaryWithHttpArgumentsString:|
  46. * removes the pluses with spaces and, as a result, cannot be used without first replacing all
  47. * instances of the plus character with '%2B'.
  48. * @param queryString The query string of a URL.
  49. * @return returns a dictionary of type <NSString *, NSString *> that represents the query.
  50. */
  51. NSDictionary *FIRDLDictionaryFromQuery(NSString *queryString);
  52. /**
  53. * @fn FIRDLDeepLinkURLWithInviteID
  54. * @abstract A method that takes the given parameters and constructs a url-scheme-based URL that can
  55. * be opened within the containing app, so that the correct link handlers are fired. This is
  56. * used after Firebase Dynamic Links either has found a pending deep link, or no link was found.
  57. * @param inviteID The invitation ID associated with the Dynamic Link. Included in App Invite URLs.
  58. * @param deepLinkString The deep link, if any, found in the response from a server lookup.
  59. * @param utmSource The UTM source, if any, found in the response from a server lookup.
  60. * @param utmMedium The UTM medium, if any, found in the response from a server lookup.
  61. * @param utmCampaign The UTM campaign, if any, found in the response from a server lookup.
  62. * @param isWeakLink This value provides information is deep link was weak-matched.
  63. * @param weakMatchEndpoint This value provides information about which endpoint, IPv4 or IPv6, was
  64. * used to perform the lookup if weak match is used.
  65. * @param minAppVersion The minimum app version string, if any, found in the response from a server
  66. * lookup. If this value is provided, the app developer can use it to determine whether or not
  67. * to handle the deep link, or to encourage their users to perhaps upgrade their app.
  68. * @param URLScheme Custom URL scheme of the Application.
  69. */
  70. NSURL *FIRDLDeepLinkURLWithInviteID(NSString *_Nullable inviteID,
  71. NSString *_Nullable deepLinkString,
  72. NSString *_Nullable utmSource,
  73. NSString *_Nullable utmMedium,
  74. NSString *_Nullable utmCampaign,
  75. BOOL isWeakLink,
  76. NSString *_Nullable weakMatchEndpoint,
  77. NSString *_Nullable minAppVersion,
  78. NSString *URLScheme,
  79. NSString *_Nullable matchMessage);
  80. /**
  81. * @fn FIRDLOSVersionSupported(NSString *systemVersion, NSString *minSupportedVersion)
  82. * @abstract Determines if the system version is greater than or equal to the minSupportedVersion.
  83. * @param systemVersion The iOS version to use as the current version in the comparison.
  84. * @param minSupportedVersion The minimum iOS system version that is supported.
  85. * @return YES if the system version is greater than or equal to the minimum, othewise, NO.
  86. */
  87. BOOL FIRDLOSVersionSupported(NSString *_Nullable systemVersion, NSString *minSupportedVersion);
  88. /**
  89. Returns date of the App installation. Return value may be nil in case of failure.
  90. */
  91. NSDate *_Nullable FIRDLAppInstallationDate(void);
  92. /**
  93. Returns current device model name.
  94. */
  95. NSString *FIRDLDeviceModelName(void);
  96. /**
  97. Returns current device locale. The method will try to bring locale format to the same format as
  98. reported by Safari/WebView.
  99. */
  100. NSString *FIRDLDeviceLocale(void) __deprecated_msg("Use FIRDeviceLocaleRaw instead");
  101. /**
  102. Returns current device locale as reported by iOS.
  103. */
  104. NSString *FIRDLDeviceLocaleRaw(void);
  105. /**
  106. Returns current device timezone.
  107. */
  108. NSString *FIRDLDeviceTimezone(void);
  109. /**
  110. Returns is universal link (long FDL link) parsable.
  111. */
  112. BOOL FIRDLCanParseUniversalLinkURL(NSURL *_Nullable URL);
  113. /**
  114. Return is link matches FDL short link format.
  115. */
  116. BOOL FIRDLMatchesShortLinkFormat(NSURL *URL);
  117. /**
  118. Returns match type string using server side match type string.
  119. Returned string can be used as customURLScheme URL with parameter kFIRDLParameterMatchType.
  120. */
  121. NSString *FIRDLMatchTypeStringFromServerString(NSString *_Nullable serverMatchTypeString);
  122. /**
  123. Add custom domains from the info.plist to the internal allowlist.
  124. */
  125. void FIRDLAddToAllowListForCustomDomainsArray(NSArray *customDomains);
  126. NS_ASSUME_NONNULL_END