FDLUtilities.h 6.6 KB

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