1515#ifndef FIREBASE_DYNAMIC_LINKS_CLIENT_CPP_SRC_INCLUDE_FIREBASE_DYNAMIC_LINKS_COMPONENTS_H_
1616#define FIREBASE_DYNAMIC_LINKS_CLIENT_CPP_SRC_INCLUDE_FIREBASE_DYNAMIC_LINKS_COMPONENTS_H_
1717
18+ #include < cstring>
1819#include < string>
1920#include < vector>
2021
@@ -230,12 +231,23 @@ struct DynamicLinkComponents {
230231 // / URL, be properly URL-encoded, and use the HTTP or HTTPS scheme.
231232 // / Note, this field is required.
232233 const char * link;
233- // / The domain (of the form "xyz.app.goo.gl") to use for this Dynamic Link.
234+ // / Deprecated: The domain (of the form "xyz.app.goo.gl") to use for this
235+ // / Dynamic Link.
234236 // /
235- // / You can find this value in the Dynamic Links section of the Firebase
237+ // / @deprecated The dynamic_link_domain field is deprecated. Use
238+ // / domain_uri_prefix instead, which also supports custom domains.
239+ FIREBASE_DEPRECATED const char * dynamic_link_domain;
240+ // / The domain (of the form "https://xyz.app.goo.gl") to use for this Dynamic
241+ // / Link. You can find this value in the Dynamic Links section of the Firebase
236242 // / console.
243+ // /
244+ // / If you have set up custom domains on your project, set this to your
245+ // / project's custom domain as listed in the Firebase console.
246+ // /
247+ // / Only https:// links are supported.
248+ // /
237249 // / Note, this field is required.
238- const char * dynamic_link_domain ;
250+ const char * domain_uri_prefix ;
239251 // / The Google Analytics parameters.
240252 GoogleAnalyticsParameters* google_analytics_parameters;
241253 // / The iOS parameters.
@@ -251,6 +263,7 @@ struct DynamicLinkComponents {
251263 DynamicLinkComponents ()
252264 : link(nullptr ),
253265 dynamic_link_domain (nullptr ),
266+ domain_uri_prefix(nullptr ),
254267 google_analytics_parameters(nullptr ),
255268 ios_parameters(nullptr ),
256269 itunes_connect_analytics_parameters(nullptr ),
@@ -260,17 +273,37 @@ struct DynamicLinkComponents {
260273 // / Constructor that initializes with the given link and domain.
261274 // /
262275 // / @param link_ The link your app will open.
263- // / @param dynamic_link_domain_ The domain (of the form "xyz.app.goo.gl") to
264- // / use for this Dynamic Link. You can find this value in the Dynamic Links
265- // / section of the Firebase console.
266- DynamicLinkComponents (const char * link_, const char * dynamic_link_domain_)
276+ // / @param domain_uri_prefix_ The domain (of the form
277+ // / "https://xyz.app.goo.gl") to use for this Dynamic Link. You can find this
278+ // / value in the Dynamic Links section of the Firebase console. If you have
279+ // / set up custom domains on your project, set this to your project's custom
280+ // / domain as listed in the Firebase console. Note: If you do not specify
281+ // / "https://" as the URI scheme, it will be added.
282+ DynamicLinkComponents (const char * link_, const char * domain_uri_prefix_)
267283 : link(link_),
268- dynamic_link_domain(dynamic_link_domain_),
284+ dynamic_link_domain(nullptr ),
285+ domain_uri_prefix(domain_uri_prefix_),
269286 google_analytics_parameters(nullptr ),
270287 ios_parameters(nullptr ),
271288 itunes_connect_analytics_parameters(nullptr ),
272289 android_parameters(nullptr ),
273- social_meta_tag_parameters(nullptr ) {}
290+ social_meta_tag_parameters(nullptr ) {
291+ // For backwards compatibility with dynamic_link_domain, if
292+ // domain_uri_prefix doesn't start with "https://", add it.
293+ static const char kHttpsPrefix [] = " https://" ;
294+ static const size_t kHttpsPrefixLength = sizeof (kHttpsPrefix ) - 1 ;
295+ if (strncmp (domain_uri_prefix, kHttpsPrefix , kHttpsPrefixLength ) != 0 ) {
296+ domain_uri_prefix_with_scheme =
297+ std::string (kHttpsPrefix ) + domain_uri_prefix;
298+ domain_uri_prefix = domain_uri_prefix_with_scheme.c_str ();
299+ }
300+ }
301+
302+ #ifndef INTERNAL_EXPERIMENTAL
303+
304+ private:
305+ #endif // INTERNAL_EXPERIMENTAL
306+ std::string domain_uri_prefix_with_scheme;
274307};
275308
276309// / Creates a long Dynamic Link from the given parameters.
0 commit comments