Skip to content

Commit ceb8392

Browse files
authored
Add warning for deprecated API to indicate that the passed in domain name's scheme will deduced as https (#2078)
* Add support for creating DL with custom domain names/paths. The new domainURIPrefix parameter requires either a. a valid FDL domain name created in the Firebase console or b. a custom domain name or c. a custom domain name with path registered for DL. All domainURIPrefixes need to start with a valid (https) scheme. * Fix style. * style * Fix typo in DEPRECATED_MSG_ATTRIBUTE, other nits. * Fix styling. * Check incoming domainURIPrefix for validity using NSURL and check for an https scheme. * Add extra checks for deprecated domain parameter being incorrectly called with a scheme. Also fix some nits. * Log a warning for the deprecated API stating that the scheme for the supplied domain will be deduced as https. * Update CHANGELOG for M38. * Update changelog for M38 * Update CHANGELOG for M38 release. * Capitalize HTTPS. * Update CHANGELOG to include PR for removal of deprecated files. * Capitalize HTTPS.
1 parent cda79a8 commit ceb8392

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

Firebase/DynamicLinks/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# v3.1.2
1+
# v3.2.0
2+
- Add support for creating and receiving dynamic links from custom domains. This feature is not yet available for public consumption. (#1962, #2017, #2078)
23
- Delete deprecated source files. (#2038)
34

45
# v3.1.1

Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m

+10-2
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,21 @@ @implementation FIRDynamicLinkComponents
452452
#pragma mark Deprecated Initializers.
453453
+ (instancetype)componentsWithLink:(NSURL *)linkdomain:(NSString *)domain {
454454
NSURL *domainURL = [NSURLURLWithString:domain];
455+
if (!domainURL.scheme) {
456+
FDLLog(FDLLogLevelWarning, FDLLogIdentifierSetupWarnHTTPSScheme,
457+
@"Only https scheme is allowed. The supplied domain's scheme will be treated as https.");
458+
}
455459
NSString *domainURIPrefix =
456460
domainURL.scheme ? domain : [NSStringstringWithFormat:@"https://%@", domain];
457461
return [FIRDynamicLinkComponents componentsWithLink:linkdomainURIPrefix:domainURIPrefix];
458462
}
459463

460464
- (instancetype)initWithLink:(NSURL *)linkdomain:(NSString *)domain {
461465
NSURL *domainURL = [NSURLURLWithString:domain];
466+
if (!domainURL.scheme) {
467+
FDLLog(FDLLogLevelWarning, FDLLogIdentifierSetupWarnHTTPSScheme,
468+
@"Only https scheme is allowed. The supplied domain's scheme will be treated as https.");
469+
}
462470
NSString *domainURIPrefix =
463471
domainURL.scheme ? domain : [NSStringstringWithFormat:@"https://%@", domain];
464472
return [selfinitWithLink:linkdomainURIPrefix:domainURIPrefix];
@@ -472,7 +480,7 @@ + (instancetype)componentsWithLink:(NSURL *)link domainURIPrefix:(NSString *)dom
472480
@"Invalid domainURIPrefix. Please input a valid URL.");
473481
returnnil;
474482
}
475-
if (![[domainURIPrefixURL.scheme lowercaseString] hasPrefix:@"https"]) {
483+
if (![[domainURIPrefixURL.scheme lowercaseString] isEqualToString:@"https"]) {
476484
FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefixScheme,
477485
@"Invalid domainURIPrefix scheme. Scheme needs to be https");
478486
returnnil;
@@ -491,7 +499,7 @@ - (instancetype)initWithLink:(NSURL *)link domainURIPrefix:(NSString *)domainURI
491499
@"Invalid domainURIPrefix. Please input a valid URL.");
492500
returnnil;
493501
}
494-
if (![[domainURIPrefixURL.scheme lowercaseString] hasPrefix:@"https"]) {
502+
if (![[domainURIPrefixURL.scheme lowercaseString] isEqualToString:@"https"]) {
495503
FDLLog(FDLLogLevelError, FDLLogIdentifierSetupInvalidDomainURIPrefixScheme,
496504
@"Invalid domainURIPrefix scheme. Scheme needs to be https");
497505
returnnil;

Firebase/DynamicLinks/Logging/FDLLogging.h

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef NS_ENUM(NSInteger, FDLLogIdentifier) {
3535
FDLLogIdentifierSetupNonDefaultApp = 2,
3636
FDLLogIdentifierSetupInvalidDomainURIPrefixScheme = 3,
3737
FDLLogIdentifierSetupInvalidDomainURIPrefix = 4,
38+
FDLLogIdentifierSetupWarnHTTPSScheme = 5,
3839
};
3940

4041
/** The appropriate formatter for using NSInteger in FIRLogger. */

Firebase/DynamicLinks/Public/FDLURLComponents.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ FIR_SWIFT_NAME(DynamicLinkComponents)
512512
* @param link Deep link to be stored in created Dynamic link. This link also called "payload" of
513513
* the Dynamic link.
514514
* @param domain Domain of your App. This value must be equal to your assigned domain from Firebase
515-
* Console.
515+
* Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is
516+
* assumed as such by this API.
516517
*/
517518
+ (instancetype)componentsWithLink:(NSURL *)link
518519
domain:(NSString *)domain
@@ -527,7 +528,8 @@ FIR_SWIFT_NAME(DynamicLinkComponents)
527528
* @param link Deep link to be stored in created Dynamic link. This link also called "payload" of
528529
* the Dynamic link.
529530
* @param domain Domain of your App. This value must be equal to your assigned domain from Firebase
530-
* Console.
531+
* Console. (e.g. xyz.page.link). Note that the domain scheme is required to be https and is
532+
* assumed as such by this API.
531533
*/
532534
- (instancetype)initWithLink:(NSURL *)link
533535
domain:(NSString *)domain

0 commit comments

Comments
 (0)
close