15
15
#ifndef FIREBASE_DYNAMIC_LINKS_CLIENT_CPP_SRC_INCLUDE_FIREBASE_DYNAMIC_LINKS_COMPONENTS_H_
16
16
#define FIREBASE_DYNAMIC_LINKS_CLIENT_CPP_SRC_INCLUDE_FIREBASE_DYNAMIC_LINKS_COMPONENTS_H_
17
17
18
+ #include < cstring>
18
19
#include < string>
19
20
#include < vector>
20
21
@@ -230,12 +231,23 @@ struct DynamicLinkComponents {
230
231
// / URL, be properly URL-encoded, and use the HTTP or HTTPS scheme.
231
232
// / Note, this field is required.
232
233
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.
234
236
// /
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
236
242
// / 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
+ // /
237
249
// / Note, this field is required.
238
- const char * dynamic_link_domain ;
250
+ const char * domain_uri_prefix ;
239
251
// / The Google Analytics parameters.
240
252
GoogleAnalyticsParameters* google_analytics_parameters;
241
253
// / The iOS parameters.
@@ -251,6 +263,7 @@ struct DynamicLinkComponents {
251
263
DynamicLinkComponents ()
252
264
: link(nullptr ),
253
265
dynamic_link_domain (nullptr ),
266
+ domain_uri_prefix(nullptr ),
254
267
google_analytics_parameters(nullptr ),
255
268
ios_parameters(nullptr ),
256
269
itunes_connect_analytics_parameters(nullptr ),
@@ -260,17 +273,37 @@ struct DynamicLinkComponents {
260
273
// / Constructor that initializes with the given link and domain.
261
274
// /
262
275
// / @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_)
267
283
: link(link_),
268
- dynamic_link_domain(dynamic_link_domain_),
284
+ dynamic_link_domain(nullptr ),
285
+ domain_uri_prefix(domain_uri_prefix_),
269
286
google_analytics_parameters(nullptr ),
270
287
ios_parameters(nullptr ),
271
288
itunes_connect_analytics_parameters(nullptr ),
272
289
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;
274
307
};
275
308
276
309
// / Creates a long Dynamic Link from the given parameters.
0 commit comments